qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-trivial] [PATCH 4/4] spice-qemu-char: convert open functions to us


From: zhanghailiang
Subject: [Qemu-trivial] [PATCH 4/4] spice-qemu-char: convert open functions to use Error API
Date: Sat, 1 Nov 2014 09:50:03 +0800

Signed-off-by: zhanghailiang <address@hidden>
---
 include/ui/qemu-spice.h     |  9 +++++----
 qemu-char.c                 |  4 ++--
 spice-qemu-char.c           | 10 +++++-----
 stubs/qemu-chr-open-spice.c |  4 ++--
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index a93b4b2..45a4737 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -27,7 +27,7 @@
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "monitor/monitor.h"
-
+#include "qapi/error.h"
 extern int using_spice;
 
 void qemu_spice_init(void);
@@ -48,12 +48,13 @@ int qemu_spice_migrate_info(const char *hostname, int port, 
int tls_port,
 void do_info_spice_print(Monitor *mon, const QObject *data);
 void do_info_spice(Monitor *mon, QObject **ret_data);
 
-CharDriverState *qemu_chr_open_spice_vmc(const char *type);
+CharDriverState *qemu_chr_open_spice_vmc(const char *type, Error **errp);
 #if SPICE_SERVER_VERSION >= 0x000c02
-CharDriverState *qemu_chr_open_spice_port(const char *name);
+CharDriverState *qemu_chr_open_spice_port(const char *name, Error **errp);
 void qemu_spice_register_ports(void);
 #else
-static inline CharDriverState *qemu_chr_open_spice_port(const char *name)
+static inline CharDriverState *qemu_chr_open_spice_port(const char *name
+                                                        Error **errp)
 { return NULL; }
 #endif
 
diff --git a/qemu-char.c b/qemu-char.c
index 52379cc..6de6221 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -4257,10 +4257,10 @@ ChardevReturn *qmp_chardev_add(const char *id, 
ChardevBackend *backend,
 #endif
 #ifdef CONFIG_SPICE
     case CHARDEV_BACKEND_KIND_SPICEVMC:
-        chr = qemu_chr_open_spice_vmc(backend->spicevmc->type);
+        chr = qemu_chr_open_spice_vmc(backend->spicevmc->type, errp);
         break;
     case CHARDEV_BACKEND_KIND_SPICEPORT:
-        chr = qemu_chr_open_spice_port(backend->spiceport->fqdn);
+        chr = qemu_chr_open_spice_port(backend->spiceport->fqdn, errp);
         break;
 #endif
     case CHARDEV_BACKEND_KIND_VC:
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 45e7d69..b693a7d 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -286,12 +286,12 @@ static CharDriverState *chr_open(const char *subtype,
     return chr;
 }
 
-CharDriverState *qemu_chr_open_spice_vmc(const char *type)
+CharDriverState *qemu_chr_open_spice_vmc(const char *type, Error **errp)
 {
     const char **psubtype = spice_server_char_device_recognized_subtypes();
 
     if (type == NULL || strlen(type) == 0) {
-        fprintf(stderr, "spice-qemu-char: missing name parameter\n");
+        error_setg(errp, "spice-qemu-char: missing name parameter");
         print_allowed_subtypes();
         return NULL;
     }
@@ -301,7 +301,7 @@ CharDriverState *qemu_chr_open_spice_vmc(const char *type)
         }
     }
     if (*psubtype == NULL) {
-        fprintf(stderr, "spice-qemu-char: unsupported type: %s\n", type);
+        error_setg(errp, "spice-qemu-char: unsupported type: %s", type);
         print_allowed_subtypes();
         return NULL;
     }
@@ -310,13 +310,13 @@ CharDriverState *qemu_chr_open_spice_vmc(const char *type)
 }
 
 #if SPICE_SERVER_VERSION >= 0x000c02
-CharDriverState *qemu_chr_open_spice_port(const char *name)
+CharDriverState *qemu_chr_open_spice_port(const char *name, Error **errp)
 {
     CharDriverState *chr;
     SpiceCharDriver *s;
 
     if (name == NULL || strlen(name) == 0) {
-        fprintf(stderr, "spice-qemu-char: missing name parameter\n");
+        error_setg(errp, "spice-qemu-char: missing name parameter");
         return NULL;
     }
 
diff --git a/stubs/qemu-chr-open-spice.c b/stubs/qemu-chr-open-spice.c
index f1c4849..98ac0b7 100644
--- a/stubs/qemu-chr-open-spice.c
+++ b/stubs/qemu-chr-open-spice.c
@@ -1,13 +1,13 @@
 #include "qemu-common.h"
 #include "ui/qemu-spice.h"
 
-CharDriverState *qemu_chr_open_spice_vmc(const char *type)
+CharDriverState *qemu_chr_open_spice_vmc(const char *type, Error **errp)
 {
     return NULL;
 }
 
 #if SPICE_SERVER_VERSION >= 0x000c02
-CharDriverState *qemu_chr_open_spice_port(const char *name)
+CharDriverState *qemu_chr_open_spice_port(const char *name, Error **errp)
 {
     return NULL;
 }
-- 
1.7.12.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]