From b25d81ba332dc06757d40ffe64944ba27082de0a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 13 Jan 2015 17:07:15 +0100 Subject: qmp hmp: Factor out common "using spice" test Into qemu_using_spice(). For want of a better place, put it next the existing monitor command handler dummies in qemu-spice.h. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Gerd Hoffmann --- include/ui/qemu-spice.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/ui/qemu-spice.h') diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index a93b4b2572..db7926d50b 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -88,4 +88,14 @@ static inline int qemu_spice_display_add_client(int csock, int skipauth, #endif /* CONFIG_SPICE */ +static inline bool qemu_using_spice(Error **errp) +{ + if (!using_spice) { + /* correct one? spice isn't a device ,,, */ + error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice"); + return false; + } + return true; +} + #endif /* QEMU_SPICE_H */ -- cgit 1.4.1 From cfa9bb236911eaa30ac58072105881a65cbbb612 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 13 Jan 2015 17:21:45 +0100 Subject: qmp hmp: Improve error messages when SPICE is not in use Commit 7572150 adopted QERR_DEVICE_NOT_ACTIVE for the purpose, probably because adding another error seemed cumbersome overkill. Produces "No spice device has been activated", which is awkward. We've since abandoned our quest for "rich" error objects. Time to undo the damage to this error message. Replace it by "SPICE is not in use". Keep the stupid DeviceNotActive ErrorClass for compatibility, even though Libvirt doesn't use it. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Gerd Hoffmann --- include/ui/qemu-spice.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/ui/qemu-spice.h') diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index db7926d50b..762e063125 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -91,8 +91,8 @@ static inline int qemu_spice_display_add_client(int csock, int skipauth, static inline bool qemu_using_spice(Error **errp) { if (!using_spice) { - /* correct one? spice isn't a device ,,, */ - error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice"); + error_set(errp, ERROR_CLASS_DEVICE_NOT_ACTIVE, + "SPICE is not in use"); return false; } return true; -- cgit 1.4.1