qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@gmail.com>
To: qemu-devel@nongnu.org
Cc: spice-devel@lists.freedesktop.org, alevy@redhat.com,
	kraxel@redhat.com,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PATCH 3/6] spice-qemu-char: factor out CharDriverState creation
Date: Fri, 30 Nov 2012 14:25:44 +0100	[thread overview]
Message-ID: <1354281947-20227-4-git-send-email-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <1354281947-20227-1-git-send-email-marcandre.lureau@redhat.com>

Make the CharDriverState creation code reusable by spicevmc port.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 spice-qemu-char.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 665efd3..b86e83a 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -186,13 +186,32 @@ static void print_allowed_subtypes(void)
     fprintf(stderr, "\n");
 }
 
-CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
+static CharDriverState *chr_open(QemuOpts *opts, const char *subtype)
 {
     CharDriverState *chr;
     SpiceCharDriver *s;
-    const char* name = qemu_opt_get(opts, "name");
     uint32_t debug = qemu_opt_get_number(opts, "debug", 0);
-    const char** psubtype = spice_server_char_device_recognized_subtypes();
+
+    chr = g_malloc0(sizeof(CharDriverState));
+    s = g_malloc0(sizeof(SpiceCharDriver));
+    s->chr = chr;
+    s->debug = debug;
+    s->active = false;
+    s->sin.subtype = subtype;
+    chr->opaque = s;
+    chr->chr_write = spice_chr_write;
+    chr->chr_close = spice_chr_close;
+    chr->chr_guest_open = spice_chr_guest_open;
+    chr->chr_guest_close = spice_chr_guest_close;
+
+    return chr;
+}
+
+CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
+{
+    CharDriverState *chr;
+    const char *name = qemu_opt_get(opts, "name");
+    const char **psubtype = spice_server_char_device_recognized_subtypes();
     const char *subtype = NULL;
 
     if (name == NULL) {
@@ -212,17 +231,7 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
         return NULL;
     }
 
-    chr = g_malloc0(sizeof(CharDriverState));
-    s = g_malloc0(sizeof(SpiceCharDriver));
-    s->chr = chr;
-    s->debug = debug;
-    s->active = false;
-    s->sin.subtype = subtype;
-    chr->opaque = s;
-    chr->chr_write = spice_chr_write;
-    chr->chr_close = spice_chr_close;
-    chr->chr_guest_open = spice_chr_guest_open;
-    chr->chr_guest_close = spice_chr_guest_close;
+    chr = chr_open(opts, subtype);
 
 #if SPICE_SERVER_VERSION < 0x000901
     /* See comment in vmc_state() */
-- 
1.7.11.7

  parent reply	other threads:[~2012-11-30 13:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-30 13:25 [Qemu-devel] [PATCH 0/6] RFC: add "spiceport" chardev Marc-André Lureau
2012-11-30 13:25 ` [Qemu-devel] [PATCH 1/6] qemu-char: add qemu_chr_remove_clients() Marc-André Lureau
2012-11-30 13:25 ` [Qemu-devel] [PATCH 2/6] spice-qemu-char: write to chardev whatever amount it can read Marc-André Lureau
2012-12-02 10:00   ` Alon Levy
2012-11-30 13:25 ` Marc-André Lureau [this message]
2012-11-30 13:25 ` [Qemu-devel] [PATCH 4/6] spice-qemu-char: add spiceport chardev Marc-André Lureau
2012-11-30 13:25 ` [Qemu-devel] [PATCH 5/6] spice-qemu-char: keep a list of spice chardev Marc-André Lureau
2012-11-30 13:25 ` [Qemu-devel] [PATCH 6/6] spice-qemu-char: register spicevmc ports during qemu_spice_init() Marc-André Lureau
2012-11-30 13:58 ` [Qemu-devel] [PATCH 0/6] RFC: add "spiceport" chardev Gerd Hoffmann
2012-11-30 14:42   ` Marc-André Lureau
2012-11-30 15:51     ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1354281947-20227-4-git-send-email-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@gmail.com \
    --cc=alevy@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=spice-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).