Luiz Capitulino wrote:
On Thu, 12 Nov 2009 08:44:03 -0600
Anthony Liguori <aligu...@linux.vnet.ibm.com> wrote:

Luiz Capitulino wrote:
#define QERR_DEVICE_ALREADY_OPEN "{'class': 'DeviceAlreadyOpen', 'data' : {'bus_num': %d, 'addr': %d}"

qemu_error_new(QERR_DEVICE_ALREADY_OPEN, bus_num, addr);
 What about DeviceAlreadyOpen errors with a different argument list?
Why would you have this? That would seem like a problem to me. I think the errors need to be very well structured (just like everything else in QMP).

 This can happen with errors that carry specific info which are different
among subsystems, eg. USB device info vs. PCI device info.

This example demonstrates the problem with this. You haven't included enough information in the error to properly distinguish what happened. I would suggest changing to:

'data' : { 'device_type' : %s, 'addr': %s }

qemu_error_new(QERR_DEVICE_ALREADY_OPEN, "pci", addr);

Or, if you really wanted to get fancy:

'data' : { 'device_type': %s, 'addr': %p }

qemu_error_new(QERR_DEVICE_ALREADY_OPEN, "pci",
qobject_from_jsonf("{'bus': %d, 'slot': %d, 'function': %d}", bus, dev, fn));

Personally, I'd stick with the first one though.

--
Regards,

Anthony Liguori



Reply via email to