From patchwork Wed Dec 5 15:15:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 203886 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B17742C00A8 for ; Thu, 6 Dec 2012 02:16:15 +1100 (EST) Received: from localhost ([::1]:41279 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgGhl-0001Dp-KU for incoming@patchwork.ozlabs.org; Wed, 05 Dec 2012 10:16:09 -0500 Received: from eggs.gnu.org ([208.118.235.92]:33280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgGha-0001DH-FN for qemu-devel@nongnu.org; Wed, 05 Dec 2012 10:16:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TgGhU-0007km-FY for qemu-devel@nongnu.org; Wed, 05 Dec 2012 10:15:58 -0500 Received: from mail-ea0-f173.google.com ([209.85.215.173]:52749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgGhU-0007kY-8z for qemu-devel@nongnu.org; Wed, 05 Dec 2012 10:15:52 -0500 Received: by mail-ea0-f173.google.com with SMTP id i13so2196644eaa.4 for ; Wed, 05 Dec 2012 07:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=vc2jUXq7MIAKmmhN6o75rRfL4pv4ikYdx3rgVf7azQQ=; b=ESLzXAjUuH1Z1RQdbRa3Wgn7nCECQb4ndkz0cGHwKaChDEgeS+aAyfYPjaiwRS/wYK DB3AN60t7+GjyQtCzZxBtaY47xlPZarzU36mC+WpQRz9Vv69QeuZ7mQgyro3ZcApBWxV IMgsEV1dPFc3dVND79NpggfsumCVilIMQVX6AwbbVB//dptG945qWrAfqirdIX5zwG5M Oj9UAsr4RjFkbIVSQP8LOhm/2Vvegif5bCJRcSky0OqbgBO/TOL3//ylxIoh3TCDhHTZ 57Ebe7go/9uEbE2VrMXclRybdJG11jZMBbNh7rE9fHT6hDJMBAUilqJOIQpG67FEuSu0 6TVA== Received: by 10.14.178.196 with SMTP id f44mr61899903eem.14.1354720551148; Wed, 05 Dec 2012 07:15:51 -0800 (PST) Received: from localhost (nat-pool-cdg-t.redhat.com. [209.132.186.20]) by mx.google.com with ESMTPS id e2sm9724937eeo.8.2012.12.05.07.15.48 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Dec 2012 07:15:50 -0800 (PST) From: "=?UTF-8?q?Marc-Andr=C3=A9=20Lureau?=" To: qemu-devel@nongnu.org Date: Wed, 5 Dec 2012 16:15:33 +0100 Message-Id: <1354720537-12097-2-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1354720537-12097-1-git-send-email-marcandre.lureau@redhat.com> References: <1354720537-12097-1-git-send-email-marcandre.lureau@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.215.173 Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , alevy@redhat.com, kraxel@redhat.com Subject: [Qemu-devel] [PATCH 2/6] spice-qemu-char: factor out CharDriverState creation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Make the CharDriverState creation code reusable by spicevmc port. --- 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() */