diff mbox

[FOR,0.12,17/18] monitor: convert do_getfd() to QError

Message ID 1260218236-22143-18-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Dec. 7, 2009, 8:37 p.m. UTC
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 monitor.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index c35a31e..0bcffbe 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2145,19 +2145,21 @@  static void do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
 
     fd = qemu_chr_get_msgfd(mon->chr);
     if (fd == -1) {
-        monitor_printf(mon, "getfd: no file descriptor supplied via SCM_RIGHTS\n");
+        qemu_error_new(QERR_FD_NOT_SUPPLIED);
         return;
     }
 
     if (qemu_isdigit(fdname[0])) {
-        monitor_printf(mon, "getfd: monitor names may not begin with a number\n");
+        qemu_error_new(QERR_INVALID_PARAMETER, "fdname");
         return;
     }
 
     fd = dup(fd);
     if (fd == -1) {
-        monitor_printf(mon, "Failed to dup() file descriptor: %s\n",
-                       strerror(errno));
+        if (errno == EMFILE)
+            qemu_error_new(QERR_TOO_MANY_FILES);
+        else
+            qemu_error_new(QERR_UNDEFINED_ERROR);
         return;
     }