* [Qemu-devel] [PATCH 1/2] Add \n to the end of fatal spice error messages
@ 2012-02-24 10:37 Christophe Fergeau
2012-02-24 10:37 ` [Qemu-devel] [PATCH 2/2] Error out when tls-channel option is used without TLS Christophe Fergeau
2012-02-24 16:47 ` [Qemu-devel] [PATCH 1/2] Add \n to the end of fatal spice error messages Gerd Hoffmann
0 siblings, 2 replies; 4+ messages in thread
From: Christophe Fergeau @ 2012-02-24 10:37 UTC (permalink / raw)
To: qemu-devel
Without it the shell prompt doesn't appear on a new line after
qemu dies.
---
ui/spice-core.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 1308a3d..6d240a3 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -568,15 +568,15 @@ void qemu_spice_init(void)
port = qemu_opt_get_number(opts, "port", 0);
tls_port = qemu_opt_get_number(opts, "tls-port", 0);
if (!port && !tls_port) {
- fprintf(stderr, "neither port nor tls-port specified for spice.");
+ fprintf(stderr, "neither port nor tls-port specified for spice.\n");
exit(1);
}
if (port < 0 || port > 65535) {
- fprintf(stderr, "spice port is out of range");
+ fprintf(stderr, "spice port is out of range\n");
exit(1);
}
if (tls_port < 0 || tls_port > 65535) {
- fprintf(stderr, "spice tls-port is out of range");
+ fprintf(stderr, "spice tls-port is out of range\n");
exit(1);
}
password = qemu_opt_get(opts, "password");
@@ -700,7 +700,7 @@ void qemu_spice_init(void)
qemu_opt_foreach(opts, add_channel, NULL, 0);
if (0 != spice_server_init(spice_server, &core_interface)) {
- fprintf(stderr, "failed to initialize spice server");
+ fprintf(stderr, "failed to initialize spice server\n");
exit(1);
};
using_spice = 1;
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/2] Error out when tls-channel option is used without TLS
2012-02-24 10:37 [Qemu-devel] [PATCH 1/2] Add \n to the end of fatal spice error messages Christophe Fergeau
@ 2012-02-24 10:37 ` Christophe Fergeau
2012-02-24 16:49 ` Gerd Hoffmann
2012-02-24 16:47 ` [Qemu-devel] [PATCH 1/2] Add \n to the end of fatal spice error messages Gerd Hoffmann
1 sibling, 1 reply; 4+ messages in thread
From: Christophe Fergeau @ 2012-02-24 10:37 UTC (permalink / raw)
To: qemu-devel
It's currently possible to setup spice channels using TLS when
no TLS port has been specified (ie TLS is disabled). This cannot
work, so better to error out in such a situation.
---
ui/spice-core.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 6d240a3..5e644c9 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -524,8 +524,11 @@ static int add_channel(const char *name, const char *value, void *opaque)
{
int security = 0;
int rc;
+ int *tls_port = opaque;
if (strcmp(name, "tls-channel") == 0) {
+ if (!*tls_port)
+ return 1;
security = SPICE_CHANNEL_SECURITY_SSL;
}
if (strcmp(name, "plaintext-channel") == 0) {
@@ -697,7 +700,10 @@ void qemu_spice_init(void)
spice_server_set_playback_compression
(spice_server, qemu_opt_get_bool(opts, "playback-compression", 1));
- qemu_opt_foreach(opts, add_channel, NULL, 0);
+ if (qemu_opt_foreach(opts, add_channel, &tls_port, 1) != 0) {
+ fprintf(stderr, "tried to setup tls-channel without specifying a TLS port\n");
+ exit(1);
+ }
if (0 != spice_server_init(spice_server, &core_interface)) {
fprintf(stderr, "failed to initialize spice server\n");
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Error out when tls-channel option is used without TLS
2012-02-24 10:37 ` [Qemu-devel] [PATCH 2/2] Error out when tls-channel option is used without TLS Christophe Fergeau
@ 2012-02-24 16:49 ` Gerd Hoffmann
0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2012-02-24 16:49 UTC (permalink / raw)
To: Christophe Fergeau; +Cc: qemu-devel
On 02/24/12 11:37, Christophe Fergeau wrote:
> It's currently possible to setup spice channels using TLS when
> no TLS port has been specified (ie TLS is disabled). This cannot
> work, so better to error out in such a situation.
> ---
> ui/spice-core.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/ui/spice-core.c b/ui/spice-core.c
> index 6d240a3..5e644c9 100644
> --- a/ui/spice-core.c
> +++ b/ui/spice-core.c
> @@ -524,8 +524,11 @@ static int add_channel(const char *name, const char *value, void *opaque)
> {
> int security = 0;
> int rc;
> + int *tls_port = opaque;
>
> if (strcmp(name, "tls-channel") == 0) {
> + if (!*tls_port)
The error message should be printed here ...
> + return 1;
> security = SPICE_CHANNEL_SECURITY_SSL;
> }
> if (strcmp(name, "plaintext-channel") == 0) {
> @@ -697,7 +700,10 @@ void qemu_spice_init(void)
> spice_server_set_playback_compression
> (spice_server, qemu_opt_get_bool(opts, "playback-compression", 1));
>
> - qemu_opt_foreach(opts, add_channel, NULL, 0);
> + if (qemu_opt_foreach(opts, add_channel, &tls_port, 1) != 0) {
> + fprintf(stderr, "tried to setup tls-channel without specifying a TLS port\n");
> + exit(1);
... otherwise we'll get a misleading error message in case add_channel()
happens fail for another reason.
cheers,
Gerd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] Add \n to the end of fatal spice error messages
2012-02-24 10:37 [Qemu-devel] [PATCH 1/2] Add \n to the end of fatal spice error messages Christophe Fergeau
2012-02-24 10:37 ` [Qemu-devel] [PATCH 2/2] Error out when tls-channel option is used without TLS Christophe Fergeau
@ 2012-02-24 16:47 ` Gerd Hoffmann
1 sibling, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2012-02-24 16:47 UTC (permalink / raw)
To: Christophe Fergeau; +Cc: qemu-devel
On 02/24/12 11:37, Christophe Fergeau wrote:
> Without it the shell prompt doesn't appear on a new line after
> qemu dies.
> ---
> ui/spice-core.c | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/ui/spice-core.c b/ui/spice-core.c
> index 1308a3d..6d240a3 100644
> --- a/ui/spice-core.c
> +++ b/ui/spice-core.c
> @@ -568,15 +568,15 @@ void qemu_spice_init(void)
> port = qemu_opt_get_number(opts, "port", 0);
> tls_port = qemu_opt_get_number(opts, "tls-port", 0);
> if (!port && !tls_port) {
> - fprintf(stderr, "neither port nor tls-port specified for spice.");
> + fprintf(stderr, "neither port nor tls-port specified for spice.\n");
Even better is this (no newline needed here):
error_report("neither port nor tls-port specified fo spice.");
> exit(1);
> }
> if (port < 0 || port > 65535) {
> - fprintf(stderr, "spice port is out of range");
> + fprintf(stderr, "spice port is out of range\n");
> exit(1);
> }
> if (tls_port < 0 || tls_port > 65535) {
> - fprintf(stderr, "spice tls-port is out of range");
> + fprintf(stderr, "spice tls-port is out of range\n");
> exit(1);
> }
> password = qemu_opt_get(opts, "password");
> @@ -700,7 +700,7 @@ void qemu_spice_init(void)
> qemu_opt_foreach(opts, add_channel, NULL, 0);
>
> if (0 != spice_server_init(spice_server, &core_interface)) {
> - fprintf(stderr, "failed to initialize spice server");
> + fprintf(stderr, "failed to initialize spice server\n");
> exit(1);
> };
> using_spice = 1;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-24 16:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-24 10:37 [Qemu-devel] [PATCH 1/2] Add \n to the end of fatal spice error messages Christophe Fergeau
2012-02-24 10:37 ` [Qemu-devel] [PATCH 2/2] Error out when tls-channel option is used without TLS Christophe Fergeau
2012-02-24 16:49 ` Gerd Hoffmann
2012-02-24 16:47 ` [Qemu-devel] [PATCH 1/2] Add \n to the end of fatal spice error messages Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).