Skip to contentSkip to conversation

e1000e: QOM property & configuration cleanups

PATCH In review Eduardo Habkost 5 participants 17 messages Oct 26, 2016 – Oct 27, 2016

lore
Share & tools
lore
#0 lore raw

cover e1000e: QOM property & configuration cleanups

This changes some of the QOM property code in e1000e so it uses regular property type macros, and the usual QOM property naming style. This also removes unnecessary configuration validation on migration/loadvm.

Some of the patches break command-line compatibility, but I am assuming those properties are not being used in production by anybody.

Eduardo Habkost (4):
e1000e: Use regular DEFINE_PROP_<type> macros for properties
e1000e: No need to validate configuration on migration
e1000e: Rename "disable_vnet_hdr" property to "vnet"
e1000e: Rename "subsys_ven" property to "subsys-vendor"

 hw/net/e1000e.c | 50 ++++++++------------------------------------------
 1 file changed, 8 insertions(+), 42 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 e1000e: Use regular DEFINE_PROP_<type> macros for properties

Instead of hacking custom PropertyInfo structs, use the regular DEFINE_PROP_<type> macros for the e1000e properties.

This also fixes a bug in the disable_vnet_hdr property definition, that was using qdev_prop_uint8 for a bool field.

---
 hw/net/e1000e.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)
hw/net/e1000e.c +3 -22
index 4994e1c..df24e55 100644
@@ -638,19 +638,11 @@ static const VMStateDescription e1000e_vmstate = {
     }
 };
 
-static PropertyInfo e1000e_prop_disable_vnet,
-                    e1000e_prop_subsys_ven,
-                    e1000e_prop_subsys;
-
 static Property e1000e_properties[] = {
     DEFINE_NIC_PROPERTIES(E1000EState, conf),
-    DEFINE_PROP_DEFAULT("disable_vnet_hdr", E1000EState, disable_vnet, false,
-                        e1000e_prop_disable_vnet, bool),
-    DEFINE_PROP_DEFAULT("subsys_ven", E1000EState, subsys_ven,
-                        PCI_VENDOR_ID_INTEL,
-                        e1000e_prop_subsys_ven, uint16_t),
-    DEFINE_PROP_DEFAULT("subsys", E1000EState, subsys, 0,
-                        e1000e_prop_subsys, uint16_t),
+    DEFINE_PROP_BOOL("disable_vnet_hdr", E1000EState, disable_vnet, false),
+    DEFINE_PROP_UINT16("subsys_ven", E1000EState, subsys_ven, PCI_VENDOR_ID_INTEL),
+    DEFINE_PROP_UINT16("subsys", E1000EState, subsys, 0),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -673,17 +665,6 @@ static void e1000e_class_init(ObjectClass *class, void *data)
     dc->vmsd = &e1000e_vmstate;
     dc->props = e1000e_properties;
 
-    e1000e_prop_disable_vnet = qdev_prop_uint8;
-    e1000e_prop_disable_vnet.description = "Do not use virtio headers, "
-                                           "perform SW offloads emulation "
-                                           "instead";
-
-    e1000e_prop_subsys_ven = qdev_prop_uint16;
-    e1000e_prop_subsys_ven.description = "PCI device Subsystem Vendor ID";
-
-    e1000e_prop_subsys = qdev_prop_uint16;
-    e1000e_prop_subsys.description = "PCI device Subsystem ID";
-
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 }
 
Signature · 1 line
2.7.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/4] e1000e: Use regular DEFINE_PROP_<type> macros for properties

Quoted 46 lines · Eduardo Habkost

Instead of hacking custom PropertyInfo structs, use the regular DEFINE_PROP_<type> macros for the e1000e properties.

This also fixes a bug in the disable_vnet_hdr property definition, that was using qdev_prop_uint8 for a bool field.

---
  hw/net/e1000e.c | 25 +++----------------------
  1 file changed, 3 insertions(+), 22 deletions(-)
hw/net/e1000e.c +3 -15
index 4994e1c..df24e55 100644
@@ -638,19 +638,11 @@ static const VMStateDescription e1000e_vmstate = {
      }
  };
 
-static PropertyInfo e1000e_prop_disable_vnet,
-                    e1000e_prop_subsys_ven,
-                    e1000e_prop_subsys;
-
  static Property e1000e_properties[] = {
      DEFINE_NIC_PROPERTIES(E1000EState, conf),
-    DEFINE_PROP_DEFAULT("disable_vnet_hdr", E1000EState, disable_vnet, false,
-                        e1000e_prop_disable_vnet, bool),
-    DEFINE_PROP_DEFAULT("subsys_ven", E1000EState, subsys_ven,
-                        PCI_VENDOR_ID_INTEL,
-                        e1000e_prop_subsys_ven, uint16_t),
-    DEFINE_PROP_DEFAULT("subsys", E1000EState, subsys, 0,
-                        e1000e_prop_subsys, uint16_t),
+    DEFINE_PROP_BOOL("disable_vnet_hdr", E1000EState, disable_vnet, false),
+    DEFINE_PROP_UINT16("subsys_ven", E1000EState, subsys_ven, PCI_VENDOR_ID_INTEL),
+    DEFINE_PROP_UINT16("subsys", E1000EState, subsys, 0),
      DEFINE_PROP_END_OF_LIST(),
  };
 
@@ -673,17 +665,6 @@ static void e1000e_class_init(ObjectClass *class, void *data)
      dc->vmsd = &e1000e_vmstate;
      dc->props = e1000e_properties;
 
-    e1000e_prop_disable_vnet = qdev_prop_uint8;
-    e1000e_prop_disable_vnet.description = "Do not use virtio headers, "
-                                           "perform SW offloads emulation "
-                                           "instead";

hw/net/e1000e.c static void e1000e_class_init(ObjectClass *class, void *data) · line 670

Quoted 10 lines
hw/net/e1000e.c +0 -7
-
-    e1000e_prop_subsys_ven = qdev_prop_uint16;
-    e1000e_prop_subsys_ven.description = "PCI device Subsystem Vendor ID";
-
-    e1000e_prop_subsys = qdev_prop_uint16;
-    e1000e_prop_subsys.description = "PCI device Subsystem ID";
-
      set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
  }
 

Is there a way to keep the description here? At least for "vnet" I believe.

Thanks

#3 lore raw

Re: [Qemu-devel] [PATCH 1/4] e1000e: Use regular DEFINE_PROP_<type> macros for properties

Quoted 53 lines · Jason Wang
Quoted 47 lines · Eduardo Habkost

Instead of hacking custom PropertyInfo structs, use the regular DEFINE_PROP_<type> macros for the e1000e properties.

This also fixes a bug in the disable_vnet_hdr property definition, that was using qdev_prop_uint8 for a bool field.

---
 hw/net/e1000e.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)
hw/net/e1000e.c +3 -17
index 4994e1c..df24e55 100644
@@ -638,19 +638,11 @@ static const VMStateDescription e1000e_vmstate = {
     }
 };
 -static PropertyInfo e1000e_prop_disable_vnet,
-                    e1000e_prop_subsys_ven,
-                    e1000e_prop_subsys;
-
 static Property e1000e_properties[] = {
     DEFINE_NIC_PROPERTIES(E1000EState, conf),
-    DEFINE_PROP_DEFAULT("disable_vnet_hdr", E1000EState, disable_vnet, false,
-                        e1000e_prop_disable_vnet, bool),
-    DEFINE_PROP_DEFAULT("subsys_ven", E1000EState, subsys_ven,
-                        PCI_VENDOR_ID_INTEL,
-                        e1000e_prop_subsys_ven, uint16_t),
-    DEFINE_PROP_DEFAULT("subsys", E1000EState, subsys, 0,
-                        e1000e_prop_subsys, uint16_t),
+    DEFINE_PROP_BOOL("disable_vnet_hdr", E1000EState, disable_vnet, false),
+    DEFINE_PROP_UINT16("subsys_ven", E1000EState, subsys_ven, PCI_VENDOR_ID_INTEL),
+    DEFINE_PROP_UINT16("subsys", E1000EState, subsys, 0),
     DEFINE_PROP_END_OF_LIST(),
 };
 @@ -673,17 +665,6 @@ static void e1000e_class_init(ObjectClass *class, void *data)
     dc->vmsd = &e1000e_vmstate;
     dc->props = e1000e_properties;
 -    e1000e_prop_disable_vnet = qdev_prop_uint8;
-    e1000e_prop_disable_vnet.description = "Do not use virtio headers, "
-                                           "perform SW offloads emulation "
-                                           "instead";
-
-    e1000e_prop_subsys_ven = qdev_prop_uint16;
-    e1000e_prop_subsys_ven.description = "PCI device Subsystem Vendor ID";
-
Quoted 8 lines

hw/net/e1000e.c static void e1000e_class_init(ObjectClass *class, void *data) · line 669

Quoted 6 lines
hw/net/e1000e.c +0 -3
-    e1000e_prop_subsys = qdev_prop_uint16;
-    e1000e_prop_subsys.description = "PCI device Subsystem ID";
-
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 }

Is there a way to keep the description here? At least for "vnet" I believe.

Actually, ability to add description was the only reason for having custom PropertyInfo structs. Does DEFINE_PROP_… macros set worth an improvement?

Quoted 2 lines

Thanks

#4 lore raw

Re: [Qemu-devel] [PATCH 1/4] e1000e: Use regular DEFINE_PROP_<type> macros for properties

Quoted 62 lines · Dmitry Fleytman
Quoted 53 lines · Jason Wang
Quoted 47 lines · Eduardo Habkost

Instead of hacking custom PropertyInfo structs, use the regular DEFINE_PROP_<type> macros for the e1000e properties.

This also fixes a bug in the disable_vnet_hdr property definition, that was using qdev_prop_uint8 for a bool field.

---
 hw/net/e1000e.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)
hw/net/e1000e.c +3 -17
index 4994e1c..df24e55 100644
@@ -638,19 +638,11 @@ static const VMStateDescription e1000e_vmstate = {
     }
 };
 -static PropertyInfo e1000e_prop_disable_vnet,
-                    e1000e_prop_subsys_ven,
-                    e1000e_prop_subsys;
-
 static Property e1000e_properties[] = {
     DEFINE_NIC_PROPERTIES(E1000EState, conf),
-    DEFINE_PROP_DEFAULT("disable_vnet_hdr", E1000EState, disable_vnet, false,
-                        e1000e_prop_disable_vnet, bool),
-    DEFINE_PROP_DEFAULT("subsys_ven", E1000EState, subsys_ven,
-                        PCI_VENDOR_ID_INTEL,
-                        e1000e_prop_subsys_ven, uint16_t),
-    DEFINE_PROP_DEFAULT("subsys", E1000EState, subsys, 0,
-                        e1000e_prop_subsys, uint16_t),
+    DEFINE_PROP_BOOL("disable_vnet_hdr", E1000EState, disable_vnet, false),
+    DEFINE_PROP_UINT16("subsys_ven", E1000EState, subsys_ven, PCI_VENDOR_ID_INTEL),
+    DEFINE_PROP_UINT16("subsys", E1000EState, subsys, 0),
     DEFINE_PROP_END_OF_LIST(),
 };
 @@ -673,17 +665,6 @@ static void e1000e_class_init(ObjectClass *class, void *data)
     dc->vmsd = &e1000e_vmstate;
     dc->props = e1000e_properties;
 -    e1000e_prop_disable_vnet = qdev_prop_uint8;
-    e1000e_prop_disable_vnet.description = "Do not use virtio headers, "
-                                           "perform SW offloads emulation "
-                                           "instead";
-
-    e1000e_prop_subsys_ven = qdev_prop_uint16;
-    e1000e_prop_subsys_ven.description = "PCI device Subsystem Vendor ID";
-
Quoted 8 lines

hw/net/e1000e.c static void e1000e_class_init(ObjectClass *class, void *data) · line 669

Quoted 6 lines
hw/net/e1000e.c +0 -3
-    e1000e_prop_subsys = qdev_prop_uint16;
-    e1000e_prop_subsys.description = "PCI device Subsystem ID";
-
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 }

Is there a way to keep the description here? At least for "vnet" I believe.

Quoted 2 lines

Actually, ability to add description was the only reason for having custom PropertyInfo structs. Does DEFINE_PROP_… macros set worth an improvement?

I think it would be reasonable to add a descrition field to struct Property.

Alternatively, you can call object_property_set_description() on instance_init.

Signature · 1 line
Eduardo
#5 lore raw

Re: [Qemu-devel] [PATCH 1/4] e1000e: Use regular DEFINE_PROP_<type> macros for properties

Quoted 63 lines · On Thu, 27 Oct 2016 09:25:27 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 62 lines · Dmitry Fleytman
Quoted 61 lines · Jason Wang
Quoted 43 lines · Eduardo Habkost

Instead of hacking custom PropertyInfo structs, use the regular DEFINE_PROP_<type> macros for the e1000e properties.

This also fixes a bug in the disable_vnet_hdr property definition, that was using qdev_prop_uint8 for a bool field.

---
 hw/net/e1000e.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)
hw/net/e1000e.c +3 -12
index 4994e1c..df24e55 100644
@@ -638,19 +638,11 @@ static const VMStateDescription e1000e_vmstate = {
     }
 };
 -static PropertyInfo e1000e_prop_disable_vnet,
-                    e1000e_prop_subsys_ven,
-                    e1000e_prop_subsys;
-
 static Property e1000e_properties[] = {
     DEFINE_NIC_PROPERTIES(E1000EState, conf),
-    DEFINE_PROP_DEFAULT("disable_vnet_hdr", E1000EState, disable_vnet, false,
-                        e1000e_prop_disable_vnet, bool),
-    DEFINE_PROP_DEFAULT("subsys_ven", E1000EState, subsys_ven,
-                        PCI_VENDOR_ID_INTEL,
-                        e1000e_prop_subsys_ven, uint16_t),
-    DEFINE_PROP_DEFAULT("subsys", E1000EState, subsys, 0,
-                        e1000e_prop_subsys, uint16_t),
+    DEFINE_PROP_BOOL("disable_vnet_hdr", E1000EState, disable_vnet, false),
+    DEFINE_PROP_UINT16("subsys_ven", E1000EState, subsys_ven, PCI_VENDOR_ID_INTEL),
+    DEFINE_PROP_UINT16("subsys", E1000EState, subsys, 0),
     DEFINE_PROP_END_OF_LIST(),
 };
 @@ -673,17 +665,6 @@ static void e1000e_class_init(ObjectClass *class, void *data)
     dc->vmsd = &e1000e_vmstate;
     dc->props = e1000e_properties;
 -    e1000e_prop_disable_vnet = qdev_prop_uint8;
-    e1000e_prop_disable_vnet.description = "Do not use virtio headers, "
-                                           "perform SW offloads emulation "

hw/net/e1000e.c static const VMStateDescription e1000e_vmstate = {

Quoted 10 lines
hw/net/e1000e.c +0 -8
-                                           "instead";
-
-    e1000e_prop_subsys_ven = qdev_prop_uint16;
-    e1000e_prop_subsys_ven.description = "PCI device Subsystem Vendor ID";
-
-    e1000e_prop_subsys = qdev_prop_uint16;
-    e1000e_prop_subsys.description = "PCI device Subsystem ID";
-
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 }

Is there a way to keep the description here? At least for "vnet" I believe.

Quoted 8 lines
Quoted 2 lines

Actually, ability to add description was the only reason for having custom PropertyInfo structs. Does DEFINE_PROP_… macros set worth an improvement?

I think it would be reasonable to add a descrition field to struct Property.

Alternatively, you can call object_property_set_description() on instance_init.

that would look sort of convoluted in case of class properties. description should be set at the same time the property is added.

Quoted 1 line
#6 lore raw

Re: [Qemu-devel] [PATCH 1/4] e1000e: Use regular DEFINE_PROP_<type> macros for properties

Quoted 69 lines · Igor Mammedov
Quoted 66 lines · On Thu, 27 Oct 2016 09:25:27 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 64 lines · Dmitry Fleytman
Quoted 53 lines · Jason Wang
Quoted 47 lines · Eduardo Habkost

Instead of hacking custom PropertyInfo structs, use the regular DEFINE_PROP_<type> macros for the e1000e properties.

This also fixes a bug in the disable_vnet_hdr property definition, that was using qdev_prop_uint8 for a bool field.

---
 hw/net/e1000e.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)
hw/net/e1000e.c +3 -17
index 4994e1c..df24e55 100644
@@ -638,19 +638,11 @@ static const VMStateDescription e1000e_vmstate = {
     }
 };
 -static PropertyInfo e1000e_prop_disable_vnet,
-                    e1000e_prop_subsys_ven,
-                    e1000e_prop_subsys;
-
 static Property e1000e_properties[] = {
     DEFINE_NIC_PROPERTIES(E1000EState, conf),
-    DEFINE_PROP_DEFAULT("disable_vnet_hdr", E1000EState, disable_vnet, false,
-                        e1000e_prop_disable_vnet, bool),
-    DEFINE_PROP_DEFAULT("subsys_ven", E1000EState, subsys_ven,
-                        PCI_VENDOR_ID_INTEL,
-                        e1000e_prop_subsys_ven, uint16_t),
-    DEFINE_PROP_DEFAULT("subsys", E1000EState, subsys, 0,
-                        e1000e_prop_subsys, uint16_t),
+    DEFINE_PROP_BOOL("disable_vnet_hdr", E1000EState, disable_vnet, false),
+    DEFINE_PROP_UINT16("subsys_ven", E1000EState, subsys_ven, PCI_VENDOR_ID_INTEL),
+    DEFINE_PROP_UINT16("subsys", E1000EState, subsys, 0),
     DEFINE_PROP_END_OF_LIST(),
 };
 @@ -673,17 +665,6 @@ static void e1000e_class_init(ObjectClass *class, void *data)
     dc->vmsd = &e1000e_vmstate;
     dc->props = e1000e_properties;
 -    e1000e_prop_disable_vnet = qdev_prop_uint8;
-    e1000e_prop_disable_vnet.description = "Do not use virtio headers, "
-                                           "perform SW offloads emulation "
-                                           "instead";
-
-    e1000e_prop_subsys_ven = qdev_prop_uint16;
-    e1000e_prop_subsys_ven.description = "PCI device Subsystem Vendor ID";
-
Quoted 8 lines

hw/net/e1000e.c static void e1000e_class_init(ObjectClass *class, void *data) · line 669

Quoted 6 lines
hw/net/e1000e.c +0 -3
-    e1000e_prop_subsys = qdev_prop_uint16;
-    e1000e_prop_subsys.description = "PCI device Subsystem ID";
-
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 }

Is there a way to keep the description here? At least for "vnet" I believe.

Actually, ability to add description was the only reason for having custom PropertyInfo structs. Does DEFINE_PROP_… macros set worth an improvement?

Quoted 7 lines
Quoted 5 lines

I think it would be reasonable to add a descrition field to struct Property.

Alternatively, you can call object_property_set_description() on instance_init.

that would look sort of convoluted in case of class properties. description should be set at the same time the property is added.

In the case of class properties, we have
object_class_property_set_description().

It's easier to redo this series on top of the qdev-class-properties series, to avoid conflicts. I will do that.

Signature · 1 line
Eduardo
#7 lore raw

PATCH 2/4 e1000e: No need to validate configuration on migration

In reply to Eduardo Habkost

The user (or management software) is responsible for keeping the same configuration on both sides while migrating. Remove the configuration validation code at e1000e_post_load, and the unnecessary subsys_used/subsys_ven_used fields.

---
 hw/net/e1000e.c | 14 --------------
 1 file changed, 14 deletions(-)
hw/net/e1000e.c +0 -14
index df24e55..a932620 100644
@@ -66,9 +66,6 @@ typedef struct E1000EState {
     uint16_t subsys_ven;
     uint16_t subsys;
 
-    uint16_t subsys_ven_used;
-    uint16_t subsys_used;
-
     bool disable_vnet;
 
     E1000ECore core;
@@ -424,9 +421,6 @@ static void e1000e_pci_realize(PCIDevice *pci_dev, Error **errp)
     pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, s->subsys_ven);
     pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID, s->subsys);
 
-    s->subsys_ven_used = s->subsys_ven;
-    s->subsys_used = s->subsys;
-
     /* Define IO/MMIO regions */
     memory_region_init_io(&s->mmio, OBJECT(s), &mmio_ops, s,
                           "e1000e-mmio", E1000E_MMIO_SIZE);
@@ -531,14 +525,6 @@ static int e1000e_post_load(void *opaque, int version_id)
 
     trace_e1000e_cb_post_load();
 
-    if ((s->subsys != s->subsys_used) ||
-        (s->subsys_ven != s->subsys_ven_used)) {
-        fprintf(stderr,
-            "ERROR: Cannot migrate while device properties "
-            "(subsys/subsys_ven) differ");
-        return -1;
-    }
-
     return e1000e_core_post_load(&s->core);
 }
 
Signature · 1 line
2.7.4
#8 lore raw

Re: [Qemu-devel] [PATCH 2/4] e1000e: No need to validate configuration on migration

Quoted 7 lines · Eduardo Habkost

The user (or management software) is responsible for keeping the same configuration on both sides while migrating. Remove the configuration validation code at e1000e_post_load, and the unnecessary subsys_used/subsys_ven_used fields.

Migration with different subsys/subsys_ven may have a really cumbersome consequences that are very hard to debug, so I believe such a verification may save a lot of time, however it’s a matter of convention.

Jason, is there specific convention for cases like this?

Quoted 48 lines

---
hw/net/e1000e.c | 14 --------------

1 file changed, 14 deletions(-)
hw/net/e1000e.c +0 -14
index df24e55..a932620 100644
@@ -66,9 +66,6 @@ typedef struct E1000EState {
    uint16_t subsys_ven;
    uint16_t subsys;
 
-    uint16_t subsys_ven_used;
-    uint16_t subsys_used;
-
    bool disable_vnet;
 
    E1000ECore core;
@@ -424,9 +421,6 @@ static void e1000e_pci_realize(PCIDevice *pci_dev, Error **errp)
    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, s->subsys_ven);
    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID, s->subsys);
 
-    s->subsys_ven_used = s->subsys_ven;
-    s->subsys_used = s->subsys;
-
    /* Define IO/MMIO regions */
    memory_region_init_io(&s->mmio, OBJECT(s), &mmio_ops, s,
                          "e1000e-mmio", E1000E_MMIO_SIZE);
@@ -531,14 +525,6 @@ static int e1000e_post_load(void *opaque, int version_id)
 
    trace_e1000e_cb_post_load();
 
-    if ((s->subsys != s->subsys_used) ||
-        (s->subsys_ven != s->subsys_ven_used)) {
-        fprintf(stderr,
-            "ERROR: Cannot migrate while device properties "
-            "(subsys/subsys_ven) differ");
-        return -1;
-    }
-
    return e1000e_core_post_load(&s->core);
 }
 
Signature · 1 line
2.7.4
#9 lore raw

Re: [Qemu-devel] [PATCH 2/4] e1000e: No need to validate configuration on migration

Quoted 8 lines · Dmitry Fleytman
Quoted 7 lines · Eduardo Habkost

The user (or management software) is responsible for keeping the same configuration on both sides while migrating. Remove the configuration validation code at e1000e_post_load, and the unnecessary subsys_used/subsys_ven_used fields.

Quoted 4 lines

Migration with different subsys/subsys_ven may have a really cumbersome consequences that are very hard to debug, so I believe such a verification may save a lot of time, however it’s a matter of convention.

The same issues apply to almost every other property on every other device. But the convention is to not expect devices to validate configuration changes on migration.

(It would be nice to have a more generic mechanism that detects configuration mismatch on migration, though. Having each device manually checking each of its properties wouldn't work).

Signature · 1 line
Eduardo
#10 lore raw

Re: [Qemu-devel] [PATCH 2/4] e1000e: No need to validate configuration on migration

Quoted 14 lines · * Eduardo Habkost ([email protected]) wrote:
Quoted 8 lines · Dmitry Fleytman
Quoted 7 lines · Eduardo Habkost

The user (or management software) is responsible for keeping the same configuration on both sides while migrating. Remove the configuration validation code at e1000e_post_load, and the unnecessary subsys_used/subsys_ven_used fields.

Quoted 4 lines

Migration with different subsys/subsys_ven may have a really cumbersome consequences that are very hard to debug, so I believe such a verification may save a lot of time, however it’s a matter of convention.

Quoted 7 lines

The same issues apply to almost every other property on every other device. But the convention is to not expect devices to validate configuration changes on migration.

(It would be nice to have a more generic mechanism that detects configuration mismatch on migration, though. Having each device manually checking each of its properties wouldn't work).

Without knowing the e1000e code, isn't the easy way to do this to change the:

        VMSTATE_UINT16(subsys, E1000EState),
        VMSTATE_UINT16(subsys_ven, E1000EState),

to

        VMSTATE_UINT16_EQUAL(subsys, E1000EState),
        VMSTATE_UINT16_EQUAL(subsys_ven, E1000EState),

and the migration code will flag if they don't match for you.

Dave

Quoted 4 lines
Signature · 2 lines
-- 
Eduardo

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#11 lore raw

Re: [Qemu-devel] [PATCH 2/4] e1000e: No need to validate configuration on migration

Quoted 26 lines · Dr. David Alan Gilbert
Quoted 14 lines · * Eduardo Habkost ([email protected]) wrote:
Quoted 8 lines · Dmitry Fleytman
Quoted 7 lines · Eduardo Habkost

The user (or management software) is responsible for keeping the same configuration on both sides while migrating. Remove the configuration validation code at e1000e_post_load, and the unnecessary subsys_used/subsys_ven_used fields.

Quoted 4 lines

Migration with different subsys/subsys_ven may have a really cumbersome consequences that are very hard to debug, so I believe such a verification may save a lot of time, however it’s a matter of convention.

Quoted 7 lines

The same issues apply to almost every other property on every other device. But the convention is to not expect devices to validate configuration changes on migration.

(It would be nice to have a more generic mechanism that detects configuration mismatch on migration, though. Having each device manually checking each of its properties wouldn't work).

Without knowing the e1000e code, isn't the easy way to do this to change the:

Quoted 8 lines
        VMSTATE_UINT16(subsys, E1000EState),
        VMSTATE_UINT16(subsys_ven, E1000EState),

to

        VMSTATE_UINT16_EQUAL(subsys, E1000EState),
        VMSTATE_UINT16_EQUAL(subsys_ven, E1000EState),

and the migration code will flag if they don't match for you.

That's very useful. I didn't know about it. I will submit a new version of the series that uses VMSTATE_UINT16_EQUAL.

Signature · 1 line
Eduardo
#12 lore raw

PATCH 3/4 e1000e: Rename "disable_vnet_hdr" property to "vnet"

In reply to Eduardo Habkost

The original commit that introduced e1000e (6f3fbe4e) mentioned a property called "vnet". The actual property name added by the patch is "disable_vnet_hdr". Rename the property so that:

1) we avoid confusing double-negatives like
"disable_vnet_hdr=false";
2) we avoid underscores in property names.

This breaks command-line compatibility, but I am assuming the property is not being used in production by anybody.

---
 hw/net/e1000e.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/net/e1000e.c +3 -3
index a932620..5a711a7 100644
@@ -66,7 +66,7 @@ typedef struct E1000EState {
     uint16_t subsys_ven;
     uint16_t subsys;
 
-    bool disable_vnet;
+    bool has_vnet;
 
     E1000ECore core;
 
@@ -327,7 +327,7 @@ e1000e_init_net_peer(E1000EState *s, PCIDevice *pci_dev, uint8_t *macaddr)
     qemu_format_nic_info_str(qemu_get_queue(s->nic), macaddr);
 
     /* Setup virtio headers */
-    if (s->disable_vnet) {
+    if (!s->has_vnet) {
         s->core.has_vnet = false;
         trace_e1000e_cfg_support_virtio(false);
         return;
@@ -626,7 +626,7 @@ static const VMStateDescription e1000e_vmstate = {
 
 static Property e1000e_properties[] = {
     DEFINE_NIC_PROPERTIES(E1000EState, conf),
-    DEFINE_PROP_BOOL("disable_vnet_hdr", E1000EState, disable_vnet, false),
+    DEFINE_PROP_BOOL("vnet", E1000EState, has_vnet, true),
     DEFINE_PROP_UINT16("subsys_ven", E1000EState, subsys_ven, PCI_VENDOR_ID_INTEL),
     DEFINE_PROP_UINT16("subsys", E1000EState, subsys, 0),
     DEFINE_PROP_END_OF_LIST(),
Signature · 1 line
2.7.4
Reviewed-by on v1 3/4
#13 lore raw

Re: [Qemu-devel] [PATCH 3/4] e1000e: Rename "disable_vnet_hdr" property to "vnet"

Quoted 9 lines · Eduardo Habkost

The original commit that introduced e1000e (6f3fbe4e) mentioned a property called "vnet". The actual property name added by the patch is "disable_vnet_hdr". Rename the property so that:

Quoted 6 lines

1) we avoid confusing double-negatives like
"disable_vnet_hdr=false";
2) we avoid underscores in property names.

This breaks command-line compatibility, but I am assuming the property is not being used in production by anybody.

Again, this patch is Ok in case command line compatibility is not an issue.

Quoted 40 lines

---
hw/net/e1000e.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
hw/net/e1000e.c +3 -3
index a932620..5a711a7 100644
@@ -66,7 +66,7 @@ typedef struct E1000EState {
    uint16_t subsys_ven;
    uint16_t subsys;
 
-    bool disable_vnet;
+    bool has_vnet;
 
    E1000ECore core;
 
@@ -327,7 +327,7 @@ e1000e_init_net_peer(E1000EState *s, PCIDevice *pci_dev, uint8_t *macaddr)
    qemu_format_nic_info_str(qemu_get_queue(s->nic), macaddr);
 
    /* Setup virtio headers */
-    if (s->disable_vnet) {
+    if (!s->has_vnet) {
        s->core.has_vnet = false;
        trace_e1000e_cfg_support_virtio(false);
        return;
@@ -626,7 +626,7 @@ static const VMStateDescription e1000e_vmstate = {
 
 static Property e1000e_properties[] = {
    DEFINE_NIC_PROPERTIES(E1000EState, conf),
-    DEFINE_PROP_BOOL("disable_vnet_hdr", E1000EState, disable_vnet, false),
+    DEFINE_PROP_BOOL("vnet", E1000EState, has_vnet, true),
    DEFINE_PROP_UINT16("subsys_ven", E1000EState, subsys_ven, PCI_VENDOR_ID_INTEL),
    DEFINE_PROP_UINT16("subsys", E1000EState, subsys, 0),
    DEFINE_PROP_END_OF_LIST(),
Signature · 1 line
2.7.4
#14 lore raw

PATCH 4/4 e1000e: Rename "subsys_ven" property to "subsys-vendor"

In reply to Eduardo Habkost

Follow the usual QOM property naming style, and make the property name clearer.

This breaks command-line compatibility, but I am assuming the property is not being used in production by anybody.

---
 hw/net/e1000e.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/net/e1000e.c +4 -5
index 5a711a7..0b27da3 100644
@@ -63,7 +63,7 @@ typedef struct E1000EState {
 
     uint32_t ioaddr;
 
-    uint16_t subsys_ven;
+    uint16_t subsys_vendor;
     uint16_t subsys;
 
     bool has_vnet;
@@ -418,7 +418,7 @@ static void e1000e_pci_realize(PCIDevice *pci_dev, Error **errp)
     pci_dev->config[PCI_CACHE_LINE_SIZE] = 0x10;
     pci_dev->config[PCI_INTERRUPT_PIN] = 1;
 
-    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, s->subsys_ven);
+    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, s->subsys_vendor);
     pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID, s->subsys);
 
     /* Define IO/MMIO regions */
@@ -524,7 +524,6 @@ static int e1000e_post_load(void *opaque, int version_id)
     E1000EState *s = opaque;
 
     trace_e1000e_cb_post_load();
-
     return e1000e_core_post_load(&s->core);
 }
 
@@ -596,7 +595,7 @@ static const VMStateDescription e1000e_vmstate = {
         VMSTATE_UINT32(core.delayed_causes, E1000EState),
 
         VMSTATE_UINT16(subsys, E1000EState),
-        VMSTATE_UINT16(subsys_ven, E1000EState),
+        VMSTATE_UINT16(subsys_vendor, E1000EState),
 
         VMSTATE_E1000E_INTR_DELAY_TIMER(core.rdtr, E1000EState),
         VMSTATE_E1000E_INTR_DELAY_TIMER(core.radv, E1000EState),
@@ -627,7 +626,7 @@ static const VMStateDescription e1000e_vmstate = {
 static Property e1000e_properties[] = {
     DEFINE_NIC_PROPERTIES(E1000EState, conf),
     DEFINE_PROP_BOOL("vnet", E1000EState, has_vnet, true),
-    DEFINE_PROP_UINT16("subsys_ven", E1000EState, subsys_ven, PCI_VENDOR_ID_INTEL),
+    DEFINE_PROP_UINT16("subsys-vendor", E1000EState, subsys_vendor, PCI_VENDOR_ID_INTEL),
     DEFINE_PROP_UINT16("subsys", E1000EState, subsys, 0),
     DEFINE_PROP_END_OF_LIST(),
 };
Signature · 1 line
2.7.4
#15 lore raw

Re: [Qemu-devel] [PATCH 4/4] e1000e: Rename "subsys_ven" property to "subsys-vendor"

Quoted 8 lines · Eduardo Habkost

Follow the usual QOM property naming style, and make the property name clearer.

This breaks command-line compatibility, but I am assuming the property is not being used in production by anybody.

I’m basically Ok with this patch in case breakage
of command line compatibility is not an issue.

Quoted 29 lines

---
hw/net/e1000e.c | 9 ++++-----

1 file changed, 4 insertions(+), 5 deletions(-)
hw/net/e1000e.c +2 -2
index 5a711a7..0b27da3 100644
@@ -63,7 +63,7 @@ typedef struct E1000EState {
 
    uint32_t ioaddr;
 
-    uint16_t subsys_ven;
+    uint16_t subsys_vendor;
    uint16_t subsys;
 
    bool has_vnet;
@@ -418,7 +418,7 @@ static void e1000e_pci_realize(PCIDevice *pci_dev, Error **errp)
    pci_dev->config[PCI_CACHE_LINE_SIZE] = 0x10;
    pci_dev->config[PCI_INTERRUPT_PIN] = 1;
 
-    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, s->subsys_ven);
+    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, s->subsys_vendor);
    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID, s->subsys);
 
    /* Define IO/MMIO regions */

hw/net/e1000e.c static int e1000e_post_load(void *opaque, int version_id) · line 527

Quoted 4 lines
hw/net/e1000e.c +0 -1
@@ -524,7 +524,6 @@ static int e1000e_post_load(void *opaque, int version_id)
    E1000EState *s = opaque;
 
    trace_e1000e_cb_post_load();
-

This hunk should not be in this patch.

Quoted 24 lines
hw/net/e1000e.c +2 -2
    return e1000e_core_post_load(&s->core);
 }
 
@@ -596,7 +595,7 @@ static const VMStateDescription e1000e_vmstate = {
        VMSTATE_UINT32(core.delayed_causes, E1000EState),
 
        VMSTATE_UINT16(subsys, E1000EState),
-        VMSTATE_UINT16(subsys_ven, E1000EState),
+        VMSTATE_UINT16(subsys_vendor, E1000EState),
 
        VMSTATE_E1000E_INTR_DELAY_TIMER(core.rdtr, E1000EState),
        VMSTATE_E1000E_INTR_DELAY_TIMER(core.radv, E1000EState),
@@ -627,7 +626,7 @@ static const VMStateDescription e1000e_vmstate = {
 static Property e1000e_properties[] = {
    DEFINE_NIC_PROPERTIES(E1000EState, conf),
    DEFINE_PROP_BOOL("vnet", E1000EState, has_vnet, true),
-    DEFINE_PROP_UINT16("subsys_ven", E1000EState, subsys_ven, PCI_VENDOR_ID_INTEL),
+    DEFINE_PROP_UINT16("subsys-vendor", E1000EState, subsys_vendor, PCI_VENDOR_ID_INTEL),
    DEFINE_PROP_UINT16("subsys", E1000EState, subsys, 0),
    DEFINE_PROP_END_OF_LIST(),
 };
Signature · 1 line
2.7.4
#16 lore raw

Re: [Qemu-devel] [PATCH 4/4] e1000e: Rename "subsys_ven" property to "subsys-vendor"

On Thu, Oct 27, 2016 at 09:45:27AM +0300, Dmitry Fleytman wrote:
[...]

Quoted 7 lines

hw/net/e1000e.c static int e1000e_post_load(void *opaque, int version_id) · line 527

Quoted 5 lines
hw/net/e1000e.c +0 -1
@@ -524,7 +524,6 @@ static int e1000e_post_load(void *opaque, int version_id)
    E1000EState *s = opaque;
 
    trace_e1000e_cb_post_load();
-

This hunk should not be in this patch.

Sorry, this is a leftover from conflict resolution when I was reordering the patches. This can be removed when committing, or I can send a new version. Jason?

Signature · 1 line
Eduardo