* [Qemu-devel] [PATCH 1/2] QError: vl.c messages
@ 2010-04-22 22:01 Leandro Dorileo
2010-04-22 22:01 ` [Qemu-devel] [PATCH 2/2] QError: vl.c drive_init porting Leandro Dorileo
0 siblings, 1 reply; 3+ messages in thread
From: Leandro Dorileo @ 2010-04-22 22:01 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel, Leandro Dorileo
Added new messages to be used(initially) on vl.c
Signed-off-by: Leandro Dorileo <ldorileo@gmail.com>
---
qerror.c | 33 +++++++++++++++++++++++++++++++++
qerror.h | 18 ++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/qerror.c b/qerror.c
index 8d885cd..92c8047 100644
--- a/qerror.c
+++ b/qerror.c
@@ -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)",
},
diff --git a/qerror.h b/qerror.h
index bae08c0..62d0af3 100644
--- a/qerror.h
+++ b/qerror.h
@@ -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 } }"
--
1.6.6.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH 2/2] QError: vl.c drive_init porting
2010-04-22 22:01 [Qemu-devel] [PATCH 1/2] QError: vl.c messages Leandro Dorileo
@ 2010-04-22 22:01 ` Leandro Dorileo
2010-04-23 7:46 ` Markus Armbruster
0 siblings, 1 reply; 3+ messages in thread
From: Leandro Dorileo @ 2010-04-22 22:01 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel, Leandro Dorileo
Port of vl.c drive_init to QError API.
Signed-off-by: Leandro Dorileo <ldorileo@gmail.com>
---
vl.c | 39 +++++++++++++++++----------------------
1 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/vl.c b/vl.c
index e58441b..5be8516 100644
--- a/vl.c
+++ b/vl.c
@@ -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;
}
--
1.6.6.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] QError: vl.c drive_init porting
2010-04-22 22:01 ` [Qemu-devel] [PATCH 2/2] QError: vl.c drive_init porting Leandro Dorileo
@ 2010-04-23 7:46 ` Markus Armbruster
0 siblings, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2010-04-23 7:46 UTC (permalink / raw)
To: Leandro Dorileo; +Cc: qemu-devel, Luiz Capitulino
Leandro Dorileo <ldorileo@gmail.com> writes:
> Port of vl.c drive_init to QError API.
>
> Signed-off-by: Leandro Dorileo <ldorileo@gmail.com>
Which QMP command are you trying to improve or create? Porting to
QError is means, not ends.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-23 7:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-22 22:01 [Qemu-devel] [PATCH 1/2] QError: vl.c messages Leandro Dorileo
2010-04-22 22:01 ` [Qemu-devel] [PATCH 2/2] QError: vl.c drive_init porting Leandro Dorileo
2010-04-23 7:46 ` Markus Armbruster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).