QError: vl.c messages
PATCH 1/2 QError: vl.c messages
Added new messages to be used(initially) on vl.c
Signed-off-by Leandro Dorileo <[email protected]>
--- qerror.c | 33 +++++++++++++++++++++++++++++++++ qerror.h | 18 ++++++++++++++++++ 2 files changed, 51 insertions(+), 0 deletions(-)
qerror.c +33 -0
@@ -129,10 +129,31 @@ static const QErrorStringTable qerror_table[] = { .desc = "Parameter '%(name)' expects %(expected)", }, { + .error_fmt = QERR_INVALID_PHYSICAL_FORMAT, + .desc = "'%(bus_type)' invalid physical %(property) format", + }, + { + .error_fmt = QERR_INVALID_PHYSICAL_NUMBER, + .desc = "'%(bus_type)' invalid physical %(property) number", + }, + { + .error_fmt = QERR_INVALID_PHYSICAL_FORMAT, + .desc = "'%(bus_type)' invalid physical %(property) format", + }, + { + .error_fmt = QERR_INVALID_PHYSICAL_NUMBER, + .desc = "'%(bus_type)' invalid physical %(property) number", + }, + + { .error_fmt = QERR_INVALID_PASSWORD, .desc = "Password incorrect", }, { + .error_fmt = QERR_INVALID_UNIT_SIZE, + .desc = "Unit %(size) too big (max is %(max_size))", + }, + { .error_fmt = QERR_JSON_PARSING, .desc = "Invalid JSON syntax", },
@@ -185,6 +206,18 @@ static const QErrorStringTable qerror_table[] = { .desc = "An undefined error has ocurred", }, { + .error_fmt = QERR_UNSUPPORTED_BUS_TYPE, + .desc = "Unsupported bus type '%(bus_type)'", + }, + { + .error_fmt = QERR_UNSUPPORTED_FLAG, + .desc = "%(flag) flag not supported for drive with %(type) interface", + }, + { + .error_fmt = QERR_UNSUPPORTED_PARAMETER_BY, + .desc = "%(parameter) is no supported by %(resource)", + }, + { .error_fmt = QERR_VNC_SERVER_FAILED, .desc = "Could not start VNC server on %(target)", },
qerror.h +18 -0
@@ -112,9 +112,18 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_INVALID_PARAMETER_VALUE \ "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }" +#define QERR_INVALID_PHYSICAL_FORMAT \ + "{ 'class': 'InvalidPhysicalFormat', 'data': { 'bus_type': %s, 'property': %s } }" + +#define QERR_INVALID_PHYSICAL_NUMBER \ + "{ 'class': 'InvalidPhysicalNumber', 'data': { 'bus_type': %s, 'property': %s } }" +#define QERR_INVALID_PASSWORD \ "{ 'class': 'InvalidPassword', 'data': {} }" +#define QERR_INVALID_UNIT_SIZE \ + "{ 'class': 'InvalidUnitSize', 'data': {size: %d, 'max_size': %d} }" +#define QERR_JSON_PARSING \ "{ 'class': 'JSONParsing', 'data': {} }"
@@ -154,6 +163,15 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_UNDEFINED_ERROR \ "{ 'class': 'UndefinedError', 'data': {} }" +#define QERR_UNSUPPORTED_BUS_TYPE \ + "{ 'class': 'UnsupportedBusType', 'data': {'bus_type': %s} }" + +#define QERR_UNSUPPORTED_FLAG \ + "{ 'class': 'UnsupportedFlag', 'data': {'flag': %s, 'type': %s} }" + +#define QERR_UNSUPPORTED_PARAMETER_BY \ + "{ 'class': 'UnsupportedParameterBy', 'data': {'parameter': %s, 'resource': %s} }" +#define QERR_VNC_SERVER_FAILED \ "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
Signature · 1 line
1.6.6.1
PATCH 2/2 QError: vl.c drive_init porting
Port of vl.c drive_init to QError API.
Signed-off-by Leandro Dorileo <[email protected]>
--- vl.c | 39 +++++++++++++++++---------------------- 1 files changed, 17 insertions(+), 22 deletions(-)
vl.c +17 -22
@@ -853,31 +853,29 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, type =IF_NONE ; max_devs =0 ; }else { -fprintf (stderr,"qemu: unsupported bus type '%s'\n" , buf); +qerror_report (QERR_UNSUPPORTED_BUS_TYPE , buf);return NULL ; } }if (cyls || heads || secs) {if (cyls <1 || (type ==IF_IDE && cyls >16383 )) { -fprintf (stderr,"qemu: '%s' invalid physical cyls number\n" , buf); +qerror_report (QERR_INVALID_PHYSICAL_NUMBER , buf,"cyls" );return NULL ; }if (heads <1 || (type ==IF_IDE && heads >16 )) { -fprintf (stderr,"qemu: '%s' invalid physical heads number\n" , buf); +qerror_report (QERR_INVALID_PHYSICAL_NUMBER , buf,"heads" );return NULL ; }if (secs <1 || (type ==IF_IDE && secs >63 )) { -fprintf (stderr,"qemu: '%s' invalid physical secs number\n" , buf); +qerror_report (QERR_INVALID_PHYSICAL_NUMBER , buf,"secs" );return NULL ; } }if ((buf =qemu_opt_get (opts,"trans" )) !=NULL ) {if (!cyls) { -fprintf (stderr, -"qemu: '%s' trans must be used with cyls,heads and secs\n" , - buf); +qerror_report (QERR_MISSING_PARAMETER ,"cyls" );return NULL ; }if (!strcmp (buf,"none" ))
@@ -887,7 +885,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,else if (!strcmp (buf,"auto" )) translation =BIOS_ATA_TRANSLATION_AUTO ;else { -fprintf (stderr,"qemu: '%s' invalid translation type\n" , buf); +qerror_report (QERR_INVALID_PARAMETER ,"trans" );return NULL ; } }
@@ -897,13 +895,12 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, media =MEDIA_DISK ; }else if (!strcmp (buf,"cdrom" )) {if (cyls || secs || heads) { -fprintf (stderr, -"qemu: '%s' invalid physical CHS format\n" , buf); +qerror_report (QERR_INVALID_PHYSICAL_FORMAT , buf,"CHS" );return NULL ; } media =MEDIA_CDROM ; }else { -fprintf (stderr,"qemu: '%s' invalid media\n" , buf); +qerror_report (QERR_INVALID_PARAMETER ,"media" );return NULL ; } }
@@ -916,7 +913,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,else if (!strcmp (buf,"writeback" )) cache =2 ;else { -fprintf (stderr,"qemu: invalid cache option\n" ); +qerror_report (QERR_INVALID_PARAMETER ,"cache" );return NULL ; } }
@@ -928,7 +925,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,else if (!strcmp (buf,"native" )) aio =1 ;else { -fprintf (stderr,"qemu: invalid aio option\n" ); +qerror_report (QERR_INVALID_PARAMETER ,"aio" );return NULL ; } }
@@ -943,7 +940,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, } drv =bdrv_find_whitelisted_format (buf);if (!drv) { -fprintf (stderr,"qemu: '%s' invalid format\n" , buf); +qerror_report (QERR_INVALID_PARAMETER ,"format" );return NULL ; } }
@@ -951,7 +948,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, on_write_error =BLOCK_ERR_STOP_ENOSPC ;if ((buf =qemu_opt_get (opts,"werror" )) !=NULL ) {if (type !=IF_IDE && type !=IF_SCSI && type !=IF_VIRTIO ) { -fprintf (stderr,"werror is no supported by this format\n" ); +qerror_report (QERR_UNSUPPORTED_PARAMETER_BY ,"werror" , devname);return NULL ; }
@@ -964,7 +961,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, on_read_error =BLOCK_ERR_REPORT ;if ((buf =qemu_opt_get (opts,"rerror" )) !=NULL ) {if (type !=IF_IDE && type !=IF_VIRTIO ) { -fprintf (stderr,"rerror is no supported by this format\n" ); +qerror_report (QERR_UNSUPPORTED_PARAMETER_BY ,"rerror" , devname);return NULL ; }
@@ -976,7 +973,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,if ((devaddr =qemu_opt_get (opts,"addr" )) !=NULL ) {if (type !=IF_VIRTIO ) { -fprintf (stderr,"addr is not supported\n" ); +qerror_report (QERR_UNSUPPORTED_PARAMETER_BY ,"addr" , devname);return NULL ; } }
@@ -1017,8 +1014,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,/* check unit id */ if (max_devs && unit_id >= max_devs) { -fprintf (stderr,"qemu: unit %d too big (max is %d)\n" , - unit_id, max_devs -1 ); +qerror_report (QERR_INVALID_UNIT_SIZE , unit_id, max_devs -1 );return NULL ; }
@@ -1122,7 +1118,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, ro =1 ; }else if (ro ==1 ) {if (type !=IF_SCSI && type !=IF_VIRTIO && type !=IF_FLOPPY ) { -fprintf (stderr,"qemu: readonly flag not supported for drive with this interface\n" ); +qerror_report (QERR_UNSUPPORTED_FLAG ,"Readonly" , devname);return NULL ; } }
@@ -1130,8 +1126,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, bdrv_flags |= ro ?0 :BDRV_O_RDWR ;if (bdrv_open2 (dinfo->bdrv, file, bdrv_flags, drv) <0 ) { -fprintf (stderr,"qemu: could not open disk image %s: %s\n" , - file,strerror (errno)); +qerror_report (QERR_OPEN_FILE_FAILED , file);return NULL ; }
Signature · 1 line
1.6.6.1
Re: [Qemu-devel] [PATCH 2/2] QError: vl.c drive_init porting
Quoted 3 lines · Leandro Dorileo
Port of
vl.cdrive_initto QError API.Signed-off-by Leandro Dorileo <[email protected]>
Which QMP command are you trying to improve or create? Porting to QError is means, not ends.