Message ID | 20130214061036.15062.11185.stgit@melchior2.sdl.hitachi.co.jp |
---|---|
State | New |
Headers | show |
On Thu, 14 Feb 2013 15:10:36 +0900 Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com> wrote: > Rename 'class' member in class_info of PciDeviceInfo to 'dev_class', and > add some casts to avoid errors from c++ compiler. [...] > # > # @class_info.desc: #optional a string description of the device's class > # > -# @class_info.class: the class code of the device > +# @class_info.dev_class: the class code of the device > # > # @id.device: the PCI device id > # > @@ -1171,7 +1171,7 @@ > ## > { 'type': 'PciDeviceInfo', > 'data': {'bus': 'int', 'slot': 'int', 'function': 'int', > - 'class_info': {'*desc': 'str', 'class': 'int'}, > + 'class_info': {'*desc': 'str', 'dev_class': 'int'}, > 'id': {'device': 'int', 'vendor': 'int'}, > '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo', > 'regions': ['PciMemoryRegion']} } The right way of doing this is to add 'class' to the set of reserved words in scripts/qapi.py:c_var(). Then you'll have to adapt the code to use the 'q_' prefix. Now, is using C++ required? Why can't you use plain C?
On 2013/02/14 21:27, Luiz Capitulino wrote: > On Thu, 14 Feb 2013 15:10:36 +0900 > Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com> wrote: > >> Rename 'class' member in class_info of PciDeviceInfo to 'dev_class', and >> add some casts to avoid errors from c++ compiler. > > [...] > >> # >> # @class_info.desc: #optional a string description of the device's class >> # >> -# @class_info.class: the class code of the device >> +# @class_info.dev_class: the class code of the device >> # >> # @id.device: the PCI device id >> # >> @@ -1171,7 +1171,7 @@ >> ## >> { 'type': 'PciDeviceInfo', >> 'data': {'bus': 'int', 'slot': 'int', 'function': 'int', >> - 'class_info': {'*desc': 'str', 'class': 'int'}, >> + 'class_info': {'*desc': 'str', 'dev_class': 'int'}, >> 'id': {'device': 'int', 'vendor': 'int'}, >> '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo', >> 'regions': ['PciMemoryRegion']} } > > The right way of doing this is to add 'class' to the set of reserved > words in scripts/qapi.py:c_var(). Then you'll have to adapt the code to > use the 'q_' prefix. Thank you for the information, I will try that. > Now, is using C++ required? Why can't you use plain C? It is because Windows COM+ framework (which VSS uses) is designed based on C++ objective programming interface. Implementing this with plain C is theoretically possible, but that will require parsing C++ objects' vtables manually so the code would be much complex. (However, It might be possible to push Windows-specific C++ stuff into a DLL to and avoid involving qemu related headers.) Thanks,
Il 15/02/2013 04:56, Tomoki Sekiyama ha scritto: > >> > Now, is using C++ required? Why can't you use plain C? > It is because Windows COM+ framework (which VSS uses) is designed based > on C++ objective programming interface. Implementing this with plain C > is theoretically possible, but that will require parsing C++ objects' > vtables manually so the code would be much complex. > (However, It might be possible to push Windows-specific C++ stuff into > a DLL to and avoid involving qemu related headers.) I don't think this is necessary. Use C++ where you see fit, as long as it's a separate file it should not be a problem. The only problem could be that we need to use the C++ compiler to link, instead of the C compiler. Paolo
diff --git a/hmp.c b/hmp.c index 1689e6f..a889c89 100644 --- a/hmp.c +++ b/hmp.c @@ -482,7 +482,7 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev) if (dev->class_info.has_desc) { monitor_printf(mon, "%s", dev->class_info.desc); } else { - monitor_printf(mon, "Class %04" PRId64, dev->class_info.class); + monitor_printf(mon, "Class %04" PRId64, dev->class_info.dev_class); } monitor_printf(mon, ": PCI device %04" PRIx64 ":%04" PRIx64 "\n", diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 905dc4a..2ca0675 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1385,7 +1385,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus, info->function = PCI_FUNC(dev->devfn); class = pci_get_word(dev->config + PCI_CLASS_DEVICE); - info->class_info.class = class; + info->class_info.dev_class = class; desc = get_class_desc(class); if (desc->desc) { info->class_info.has_desc = true; diff --git a/qapi-schema.json b/qapi-schema.json index cdd8384..413df5c 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1150,7 +1150,7 @@ # # @class_info.desc: #optional a string description of the device's class # -# @class_info.class: the class code of the device +# @class_info.dev_class: the class code of the device # # @id.device: the PCI device id # @@ -1171,7 +1171,7 @@ ## { 'type': 'PciDeviceInfo', 'data': {'bus': 'int', 'slot': 'int', 'function': 'int', - 'class_info': {'*desc': 'str', 'class': 'int'}, + 'class_info': {'*desc': 'str', 'dev_class': 'int'}, 'id': {'device': 'int', 'vendor': 'int'}, '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo', 'regions': ['PciMemoryRegion']} }
Rename 'class' member in class_info of PciDeviceInfo to 'dev_class', and add some casts to avoid errors from c++ compiler. Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com> --- hmp.c | 2 +- hw/pci/pci.c | 2 +- qapi-schema.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)