[libvirt] [PATCH] qemu: Substitute VIR_ERR_NO_SUPPORT with VIR_ERR_OPERATION_INVALID

* src/qemu/qemu_monitor_text.c: Error like "this function is not supported by the connection driver" is confused obviously. --- src/qemu/qemu_monitor_text.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index d296675..4a7c242 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -713,7 +713,7 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon, * to detect if qemu supports the command. */ if (strstr(info, "\ninfo ")) { - qemuReportError(VIR_ERR_NO_SUPPORT, + qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", _("'info blockstats' not supported by this qemu")); goto cleanup; @@ -1388,7 +1388,7 @@ int qemuMonitorTextMigrate(qemuMonitorPtr mon, /* If the command isn't supported then qemu prints: * unknown command: migrate" */ if (strstr(info, "unknown command:")) { - qemuReportError(VIR_ERR_NO_SUPPORT, + qemuReportError(VIR_ERR_OPERATION_INVALID, _("migration to '%s' not supported by this qemu: %s"), dest, info); goto cleanup; } @@ -1652,7 +1652,7 @@ int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon, } if (strstr(reply, "invalid type: host")) { - qemuReportError(VIR_ERR_NO_SUPPORT, "%s", + qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", _("PCI device assignment is not supported by this version of qemu")); goto cleanup; } -- 1.7.6

On 08/22/2011 08:12 AM, Osier Yang wrote:
* src/qemu/qemu_monitor_text.c: Error like "this function is not supported by the connection driver" is confused obviously. --- src/qemu/qemu_monitor_text.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
ACK. You are correct that VIR_ERR_NO_SUPPORT should only be used in libvirt.c, and not in any of the drivers. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

于 2011年08月22日 21:54, Eric Blake 写道:
On 08/22/2011 08:12 AM, Osier Yang wrote:
* src/qemu/qemu_monitor_text.c: Error like "this function is not supported by the connection driver" is confused obviously. --- src/qemu/qemu_monitor_text.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
ACK.
You are correct that VIR_ERR_NO_SUPPORT should only be used in libvirt.c, and not in any of the drivers.
# grep VIR_ERR_NO_SUPPORT * -r --exclude="libvirt.c" | grep -v '^Binary' | wc -l 115 Agree, seems we need to do a big cleanup. But seems it's fine for funcs like below to use that? int virSecurityManagerSetAllLabel(virSecurityManagerPtr mgr, virDomainObjPtr vm, const char *stdin_path) { if (mgr->drv->domainSetSecurityAllLabel) return mgr->drv->domainSetSecurityAllLabel(mgr, vm, stdin_path); virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); return -1; } Osier

On 08/22/2011 08:50 AM, Osier Yang wrote:
But seems it's fine for funcs like below to use that?
int virSecurityManagerSetAllLabel(virSecurityManagerPtr mgr, virDomainObjPtr vm, const char *stdin_path) { if (mgr->drv->domainSetSecurityAllLabel) return mgr->drv->domainSetSecurityAllLabel(mgr, vm, stdin_path);
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
Uses like this are fine. That is, VIR_ERR_NO_SUPPORT is for use by managers (libvirt.c is a manager, but so is virSecurityManagerSetAllLabel) to report that a function callback is not supported by a driver. Where it is not okay is within a driver (either the driver implemented the callback, so there is no error to report, or the driver does not implement the callback, so the manager already reported the error). -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

于 2011年08月22日 21:54, Eric Blake 写道:
On 08/22/2011 08:12 AM, Osier Yang wrote:
* src/qemu/qemu_monitor_text.c: Error like "this function is not supported by the connection driver" is confused obviously. --- src/qemu/qemu_monitor_text.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
ACK.
You are correct that VIR_ERR_NO_SUPPORT should only be used in libvirt.c, and not in any of the drivers.
Pushed Osier
participants (2)
-
Eric Blake
-
Osier Yang