Because of my patch last week that converted the various virStorage*FromString

and virStorage*ToString implementations to the generic VIR_ENUM_IMPL, there were
a couple of places that didn't properly set errors when they failed.  This patch
fixes these places up.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
This commit is contained in:
Chris Lalancette 2008-10-21 17:18:45 +00:00
parent c83c3e9e5c
commit 46db2b2968
2 changed files with 18 additions and 2 deletions

View File

@ -1,3 +1,7 @@
Tue Oct 21 19:18:00 CEST 2008 Chris Lalancette <clalance@redhat.com>
* src/storage_conf.c: Make sure to set errors on paths where
->formatToString() or ->formatFromString() fail.
Tue Oct 21 19:13:00 CEST 2008 Chris Lalancette <clalance@redhat.com> Tue Oct 21 19:13:00 CEST 2008 Chris Lalancette <clalance@redhat.com>
* src/qemu_driver.c src/storage_conf.c src/network_driver.c * src/qemu_driver.c src/storage_conf.c src/network_driver.c
src/storage_driver.c: Shore up the uses of virGetLastError() so that src/storage_driver.c: Shore up the uses of virGetLastError() so that

View File

@ -276,6 +276,8 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
if (options->formatFromString) { if (options->formatFromString) {
char *format = virXPathString(conn, "string(/pool/source/format/@type)", ctxt); char *format = virXPathString(conn, "string(/pool/source/format/@type)", ctxt);
if ((ret->source.format = (options->formatFromString)(format)) < 0) { if ((ret->source.format = (options->formatFromString)(format)) < 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
_("unknown pool format type %s"), format);
VIR_FREE(format); VIR_FREE(format);
goto cleanup; goto cleanup;
} }
@ -521,8 +523,12 @@ virStoragePoolDefFormat(virConnectPtr conn,
if (options->formatToString) { if (options->formatToString) {
const char *format = (options->formatToString)(def->source.format); const char *format = (options->formatToString)(def->source.format);
if (!format) if (!format) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("unknown pool format number %d"),
def->source.format);
goto cleanup; goto cleanup;
}
virBufferVSprintf(&buf," <format type='%s'/>\n", format); virBufferVSprintf(&buf," <format type='%s'/>\n", format);
} }
@ -751,6 +757,8 @@ virStorageVolDefParseDoc(virConnectPtr conn,
if (options->formatFromString) { if (options->formatFromString) {
char *format = virXPathString(conn, "string(/volume/target/format/@type)", ctxt); char *format = virXPathString(conn, "string(/volume/target/format/@type)", ctxt);
if ((ret->target.format = (options->formatFromString)(format)) < 0) { if ((ret->target.format = (options->formatFromString)(format)) < 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
_("unknown volume format type %s"), format);
VIR_FREE(format); VIR_FREE(format);
goto cleanup; goto cleanup;
} }
@ -885,8 +893,12 @@ virStorageVolDefFormat(virConnectPtr conn,
if (options->formatToString) { if (options->formatToString) {
const char *format = (options->formatToString)(def->target.format); const char *format = (options->formatToString)(def->target.format);
if (!format) if (!format) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("unknown volume format number %d"),
def->target.format);
goto cleanup; goto cleanup;
}
virBufferVSprintf(&buf," <format type='%s'/>\n", format); virBufferVSprintf(&buf," <format type='%s'/>\n", format);
} }