pci-bridge/i82801b11: Convert to realize
PATCH 1/1 pci-bridge/i82801b11: Convert to realize
The pci-birdge device i82801b11 still implements the old PCIDeviceClass .init() through i82801b11_bridge_init() instead of the new .realize(). All devices need to be converted to .realize(). So convert it and rename it to i82801b11_bridge_realize().
--- hw/pci-bridge/i82801b11.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
hw/pci-bridge/i82801b11.c +4 -5
@@ -44,6 +44,7 @@#include "qemu/osdep.h" #include "hw/pci/pci.h" #include "hw/i386/ich9.h" +#include "qapi/error.h" /*****************************************************************************/
@@ -58,7 +59,7 @@ typedef struct I82801b11Bridge {/*< public >*/ } I82801b11Bridge; -static int i82801b11_bridge_initfn (PCIDevice *d) +static void i82801b11_bridge_realize (PCIDevice *d,Error **errp) {int rc;
@@ -70,12 +71,10 @@ static int i82801b11_bridge_initfn(PCIDevice *d) goto err_bridge; }pci_config_set_prog_interface (d->config,PCI_CLASS_BRIDGE_PCI_INF_SUB ); -return 0 ; +return ; err_bridge:pci_bridge_exitfn (d); - -return rc; }static const VMStateDescription i82801b11_bridge_dev_vmstate = {
@@ -95,7 +94,7 @@ static void i82801b11_bridge_class_init(ObjectClass *klass, void *data) k->vendor_id =PCI_VENDOR_ID_INTEL ; k->device_id =PCI_DEVICE_ID_INTEL_82801BA_11 ; k->revision =ICH9_D2P_A2_REVISION ; - k->init = i82801b11_bridge_initfn; + k->realize = i82801b11_bridge_realize; k->config_write = pci_bridge_write_config; dc->vmsd = &i82801b11_bridge_dev_vmstate;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories);
Signature · 1 line
2.9.3
Quoted 33 lines · Mao Zhongyi
The pci-birdge device i82801b11 still implements the old PCIDeviceClass .init() through
i82801b11_bridge_init()instead of the new .realize(). All devices need to be converted to .realize(). So convert it and rename it toi82801b11_bridge_realize().Signed-off-by Mao Zhongyi <[email protected]>--- hw/pci-bridge/i82801b11.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)hw/pci-bridge/i82801b11.c +2
-1@@ -44,6 +44,7 @@#include "qemu/osdep.h" #include "hw/pci/pci.h" #include "hw/i386/ich9.h" +#include "qapi/error.h" /*****************************************************************************/ @@ -58,7 +59,7 @@ typedef struct I82801b11Bridge {/*< public >*/ } I82801b11Bridge; -static int i82801b11_bridge_initfn (PCIDevice *d) +static void i82801b11_bridge_realize (PCIDevice *d,Error **errp) {int rc;
hw/pci-bridge/i82801b11.c static int i82801b11_bridge_initfn(PCIDevice *d) · line 77
Quoted 8 lines
hw/pci-bridge/i82801b11.c +1
-1@@ -70,12 +71,10 @@ static int i82801b11_bridge_initfn(PCIDevice *d) goto err_bridge; }pci_config_set_prog_interface (d->config,PCI_CLASS_BRIDGE_PCI_INF_SUB ); -return 0 ; +return ; err_bridge:pci_bridge_exitfn (d);
Hi,
Since you move to realize, you may want to leverage the errp to add info on errors.
Thanks,
Marcel
Quoted 14 lines
hw/pci-bridge/i82801b11.c +1
-3- -return rc; }static const VMStateDescription i82801b11_bridge_dev_vmstate = {@@ -95,7 +94,7 @@ static void i82801b11_bridge_class_init(ObjectClass *klass, void *data) k->vendor_id =PCI_VENDOR_ID_INTEL ; k->device_id =PCI_DEVICE_ID_INTEL_82801BA_11 ; k->revision =ICH9_D2P_A2_REVISION ; - k->init = i82801b11_bridge_initfn; + k->realize = i82801b11_bridge_realize; k->config_write = pci_bridge_write_config; dc->vmsd = &i82801b11_bridge_dev_vmstate;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories);
Quoted 42 lines · Marcel Apfelbaum
Quoted 26 lines · Mao Zhongyi
The pci-birdge device i82801b11 still implements the old PCIDeviceClass .init() through
i82801b11_bridge_init()instead of the new .realize(). All devices need to be converted to .realize(). So convert it and rename it toi82801b11_bridge_realize().Signed-off-by Mao Zhongyi <[email protected]>--- hw/pci-bridge/i82801b11.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)hw/pci-bridge/i82801b11.c +2
-0@@ -44,6 +44,7 @@#include "qemu/osdep.h" #include "hw/pci/pci.h" #include "hw/i386/ich9.h" +#include "qapi/error.h" /*****************************************************************************/ @@ -58,7 +59,7 @@ typedef struct I82801b11Bridge {/*< public >*/ } I82801b11Bridge; -static int i82801b11_bridge_initfn(PCIDevice *d) +static void i82801b11_bridge_realize(PCIDevice *d, Error **errp)hw/pci-bridge/i82801b11.c typedef struct I82801b11Bridge { · line 77
Quoted 10 lines
hw/pci-bridge/i82801b11.c +1
-1{int rc; @@ -70,12 +71,10 @@ static int i82801b11_bridge_initfn(PCIDevice *d) goto err_bridge; }pci_config_set_prog_interface (d->config,PCI_CLASS_BRIDGE_PCI_INF_SUB ); -return 0 ; +return ; err_bridge:pci_bridge_exitfn (d);Hi,
Quoted 5 lines
Since you move to realize, you may want to leverage the errp to add info on errors.
Thanks,
Marcel
Hi, Marcel
Thanks for your quick reply and advice. In fact, I have considered adding an error message to errp when an error occurs. But I found that pci_bridge_ssvid_init() has reported a specific info when it fails. If the error is reported here again, it seems a bit more superfluous, so it's not adopted. Of course, output a readable error info to make it easier for users is also a good choice. So, are you sure you want to do that?
Look forward to your feedback and suggestion soon.
Thanks a lot.
Mao
Quoted 1 line
Quoted 46 lines · Mao Zhongyi
Quoted 43 lines · Marcel Apfelbaum
Quoted 33 lines · Mao Zhongyi
The pci-birdge device i82801b11 still implements the old PCIDeviceClass .init() through
i82801b11_bridge_init()instead of the new .realize(). All devices need to be converted to .realize(). So convert it and rename it toi82801b11_bridge_realize().Signed-off-by Mao Zhongyi <[email protected]>--- hw/pci-bridge/i82801b11.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)hw/pci-bridge/i82801b11.c +2
-0@@ -44,6 +44,7 @@#include "qemu/osdep.h" #include "hw/pci/pci.h" #include "hw/i386/ich9.h" +#include "qapi/error.h" /*****************************************************************************/ @@ -58,7 +59,7 @@ typedef struct I82801b11Bridge {/*< public >*/ } I82801b11Bridge; -static int i82801b11_bridge_initfn(PCIDevice *d) +static void i82801b11_bridge_realize(PCIDevice *d, Error **errp) {int rc; @@ -70,12 +71,10 @@ static int i82801b11_bridge_initfn(PCIDevice *d) goto err_bridge; } pci_config_set_prog_interface(d->config,
PCI_CLASS_BRIDGE_PCI_INF_SUB);hw/pci-bridge/i82801b11.c static int i82801b11_bridge_initfn(PCIDevice *d) · line 77
Quoted 4 lines
hw/pci-bridge/i82801b11.c +1
-1-return 0 ; +return ; err_bridge:pci_bridge_exitfn (d);Hi,
Quoted 9 lines
Quoted 5 lines
Since you move to realize, you may want to leverage the errp to add info on errors.
Thanks,
MarcelHi, Marcel
Hi!
Quoted 4 lines
Thanks for your quick reply and advice. In fact, I have considered adding an error message to errp when an error occurs. But I found that
pci_bridge_ssvid_init()has reported a specific info when it fails. If the error is reported here again, it seems a bit more superfluous, so it's not adopted.
I agree we don't want to see the error twice, but that means we may want to pass the error pointer to pci_bridge_ssvid_init and so on. One of the main things we achieve when moving to 'realize' is better error handling, so if we don't do that maybe is not worth it.
You may need to do several changes you didn't intend to in order to do the error propagation right...
Thanks,
Marcel
Quoted 30 lines
Of course, output a readable error info
to make it easier for users is also a good choice. So, are you sure you want to do that?Look forward to your feedback and suggestion soon.
Thanks a lot.
MaoQuoted 1 line
Quoted 66 lines · Marcel Apfelbaum
Quoted 46 lines · Mao Zhongyi
Quoted 43 lines · Marcel Apfelbaum
Quoted 33 lines · Mao Zhongyi
The pci-birdge device i82801b11 still implements the old PCIDeviceClass .init() through
i82801b11_bridge_init()instead of the new .realize(). All devices need to be converted to .realize(). So convert it and rename it toi82801b11_bridge_realize().Signed-off-by Mao Zhongyi <[email protected]>--- hw/pci-bridge/i82801b11.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)hw/pci-bridge/i82801b11.c +2
-0@@ -44,6 +44,7 @@#include "qemu/osdep.h" #include "hw/pci/pci.h" #include "hw/i386/ich9.h" +#include "qapi/error.h" /*****************************************************************************/ @@ -58,7 +59,7 @@ typedef struct I82801b11Bridge {/*< public >*/ } I82801b11Bridge; -static int i82801b11_bridge_initfn(PCIDevice *d) +static void i82801b11_bridge_realize(PCIDevice *d, Error **errp) {int rc; @@ -70,12 +71,10 @@ static int i82801b11_bridge_initfn(PCIDevice *d) goto err_bridge; } pci_config_set_prog_interface(d->config,
PCI_CLASS_BRIDGE_PCI_INF_SUB);hw/pci-bridge/i82801b11.c static int i82801b11_bridge_initfn(PCIDevice *d) · line 77
Quoted 4 lines
hw/pci-bridge/i82801b11.c +1
-1-return 0 ; +return ; err_bridge:pci_bridge_exitfn (d);Hi,
Quoted 9 lines
Quoted 5 lines
Since you move to realize, you may want to leverage the errp to add info on errors.
Thanks,
MarcelHi, Marcel
Hi!
Quoted 7 lines
Thanks for your quick reply and advice. In fact, I have considered adding an error
message to errp when an error occurs. But I found thatpci_bridge_ssvid_init()has
reported a specific info when it fails. If the error is reported here again, it seems
a bit more superfluous, so it's not adopted.
Quoted 2 lines
I agree we don't want to see the error twice, but that means we may want to pass the error pointer to
pci_bridge_ssvid_initand so on.
Yes.
Callees that report errors differently are a common issue when converting a function to Error. The correct solution is to convert these callees to Error, too.
Sometimes, this is just too much to be practical. Then a "shallow" conversion can make sense as a stop-gap, even though it'll result in clearly inferior error reporting.
At a glance, this one doesn't look impractical.
Quoted 2 lines
One of the main things we achieve when moving to 'realize' is better error handling, so if we don't do that maybe is not worth it.
We need to convert all devices to realize() so we can get rid of the old qdev methods. But you're right in that we better convert them correctly.
Quoted 2 lines
You may need to do several changes you didn't intend to in order to do the error propagation right...
Yes. An Error conversion can look simple at first, then balloon into a multi-part series.
Quoted 13 lines
Thanks,
MarcelQuoted 9 lines
Of course, output a readable error info
to make it easier for users is also a good choice. So, are you sure you want to do
that?Look forward to your feedback and suggestion soon.
Thanks a lot.
Mao
Any help with converting the remaining devices to realize() is much appreciated.
Hi, Marcel & Markus
Quoted 105 lines · Markus Armbruster
Quoted 66 lines · Marcel Apfelbaum
Quoted 46 lines · Mao Zhongyi
Quoted 43 lines · Marcel Apfelbaum
Quoted 33 lines · Mao Zhongyi
The pci-birdge device i82801b11 still implements the old PCIDeviceClass .init() through
i82801b11_bridge_init()instead of the new .realize(). All devices need to be converted to .realize(). So convert it and rename it toi82801b11_bridge_realize().Signed-off-by Mao Zhongyi <[email protected]>--- hw/pci-bridge/i82801b11.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)hw/pci-bridge/i82801b11.c +2
-0@@ -44,6 +44,7 @@#include "qemu/osdep.h" #include "hw/pci/pci.h" #include "hw/i386/ich9.h" +#include "qapi/error.h" /*****************************************************************************/ @@ -58,7 +59,7 @@ typedef struct I82801b11Bridge {/*< public >*/ } I82801b11Bridge; -static int i82801b11_bridge_initfn(PCIDevice *d) +static void i82801b11_bridge_realize(PCIDevice *d, Error **errp) {int rc; @@ -70,12 +71,10 @@ static int i82801b11_bridge_initfn(PCIDevice *d) goto err_bridge; } pci_config_set_prog_interface(d->config,
PCI_CLASS_BRIDGE_PCI_INF_SUB);hw/pci-bridge/i82801b11.c static int i82801b11_bridge_initfn(PCIDevice *d) · line 77
Quoted 4 lines
hw/pci-bridge/i82801b11.c +1
-1-return 0 ; +return ; err_bridge:pci_bridge_exitfn (d);Hi,
Quoted 9 lines
Quoted 5 lines
Since you move to realize, you may want to leverage the errp to add info on errors.
Thanks,
MarcelHi, Marcel
Hi!
Quoted 7 lines
Thanks for your quick reply and advice. In fact, I have considered adding an error
message to errp when an error occurs. But I found thatpci_bridge_ssvid_init()has
reported a specific info when it fails. If the error is reported here again, it seems
a bit more superfluous, so it's not adopted.Quoted 2 lines
I agree we don't want to see the error twice, but that means we may want to pass the error pointer to
pci_bridge_ssvid_initand so on.Yes.
Callees that report errors differently are a common issue when converting a function to Error. The correct solution is to convert these callees to Error, too.
Sometimes, this is just too much to be practical. Then a "shallow" conversion can make sense as a stop-gap, even though it'll result in clearly inferior error reporting.
At a glance, this one doesn't look impractical.
Quoted 2 lines
One of the main things we achieve when moving to 'realize' is better error handling, so if we don't do that maybe is not worth it.
We need to convert all devices to
realize()so we can get rid of the old qdev methods. But you're right in that we better convert them correctly.Quoted 2 lines
You may need to do several changes you didn't intend to in order to do the error propagation right...
Yes. An Error conversion can look simple at first, then balloon into a multi-part series.
Quoted 9 lines
Thanks,
MarcelQuoted 5 lines
Of course, output a readable error info
to make it easier for users is also a good choice. So, are you sure you want to do
that?
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Look forward to your feedback and suggestion soon.
Thanks a lot.
MaoAny help with converting the remaining devices to
realize()is much appreciated.
Thanks for your detailed explanation, I think I know what to do.
Thanks,
Mao