From patchwork Wed Aug 19 23:07:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 31685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 80566B70CF for ; Thu, 20 Aug 2009 09:30:52 +1000 (EST) Received: from localhost ([127.0.0.1]:34548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mduc5-0001TH-B5 for incoming@patchwork.ozlabs.org; Wed, 19 Aug 2009 19:30:41 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MduHG-00021k-QP for qemu-devel@nongnu.org; Wed, 19 Aug 2009 19:09:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MduHC-0001zr-Rc for qemu-devel@nongnu.org; Wed, 19 Aug 2009 19:09:10 -0400 Received: from [199.232.76.173] (port=49895 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MduHC-0001zk-J0 for qemu-devel@nongnu.org; Wed, 19 Aug 2009 19:09:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53218) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MduHB-0005WP-Ss for qemu-devel@nongnu.org; Wed, 19 Aug 2009 19:09:06 -0400 Received: from int-mx06.intmail.prod.int.phx2.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.19]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7JN94l2001131; Wed, 19 Aug 2009 19:09:04 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx06.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7JN93cO013609; Wed, 19 Aug 2009 19:09:03 -0400 Received: from localhost (vpn-10-5.bos.redhat.com [10.16.10.5]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n7JN92YT031982; Wed, 19 Aug 2009 19:09:02 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 19 Aug 2009 20:07:43 -0300 Message-Id: <1250723280-3509-13-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1250723280-3509-1-git-send-email-lcapitulino@redhat.com> References: <1250723280-3509-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.19 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, avi@redhat.com Subject: [Qemu-devel] [PATCH 12/29] monitor: Port handler_3 to use QDict X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This commit ports command handlers that receive three arguments to use the new monitor's dictionary. Signed-off-by: Luiz Capitulino --- hw/pci-hotplug.c | 6 ++++-- monitor.c | 27 ++++++++++++++++----------- net.c | 12 ++++++++---- net.h | 6 ++---- sysemu.h | 3 +-- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index e729158..feb2aba 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -148,10 +148,12 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, return dev; } -void pci_device_hot_add(Monitor *mon, const char *pci_addr, const char *type, - const char *opts) +void pci_device_hot_add(Monitor *mon, const QDict *qdict) { PCIDevice *dev = NULL; + const char *pci_addr = qdict_get_str(qdict, "pci_addr"); + const char *type = qdict_get_str(qdict, "type"); + const char *opts = qdict_get_str(qdict, "opts"); /* strip legacy tag */ if (!strncmp(pci_addr, "pci_addr=", 9)) { diff --git a/monitor.c b/monitor.c index 36bafbd..77fff17 100644 --- a/monitor.c +++ b/monitor.c @@ -517,9 +517,11 @@ static void do_change_vnc(Monitor *mon, const char *target, const char *arg) } } -static void do_change(Monitor *mon, const char *device, const char *target, - const char *arg) +static void do_change(Monitor *mon, const QDict *qdict) { + const char *device = qdict_get_str(qdict, "device"); + const char *target = qdict_get_str(qdict, "target"); + const char *arg = qdict_get_str(qdict, "arg"); if (strcmp(device, "vnc") == 0) { do_change_vnc(mon, target, arg); } else { @@ -1112,12 +1114,17 @@ static void release_keys(void *opaque) } } -static void do_sendkey(Monitor *mon, const char *string, int has_hold_time, - int hold_time) +static void do_sendkey(Monitor *mon, const QDict *qdict) { char keyname_buf[16]; char *separator; int keyname_len, keycode, i; + const char *string = qdict_get_str(qdict, "string"); + int has_hold_time = qdict_exists(qdict, "hold_time"); + int hold_time = -1; + + if (has_hold_time) + hold_time = qdict_get_int(qdict, "hold_time"); if (nb_pending_keycodes > 0) { qemu_del_timer(key_timer); @@ -1166,10 +1173,12 @@ static void do_sendkey(Monitor *mon, const char *string, int has_hold_time, static int mouse_button_state; -static void do_mouse_move(Monitor *mon, const char *dx_str, const char *dy_str, - const char *dz_str) +static void do_mouse_move(Monitor *mon, const QDict *qdict) { int dx, dy, dz; + const char *dx_str = qdict_get_str(qdict, "dx_str"); + const char *dy_str = qdict_get_str(qdict, "dy_str"); + const char *dz_str = qdict_get_str(qdict, "dz_str"); dx = strtol(dx_str, NULL, 0); dy = strtol(dy_str, NULL, 0); dz = 0; @@ -2625,7 +2634,6 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline) void *str_allocated[MAX_ARGS]; void *args[MAX_ARGS]; void (*handler_d)(Monitor *mon, const QDict *qdict); - void (*handler_3)(Monitor *mon, void *arg0, void *arg1, void *arg2); void (*handler_4)(Monitor *mon, void *arg0, void *arg1, void *arg2, void *arg3); void (*handler_5)(Monitor *mon, void *arg0, void *arg1, void *arg2, @@ -2917,13 +2925,10 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline) case 0: case 1: case 2: + case 3: handler_d = cmd->handler; handler_d(mon, qdict); break; - case 3: - handler_3 = cmd->handler; - handler_3(mon, args[0], args[1], args[2]); - break; case 4: handler_4 = cmd->handler; handler_4(mon, args[0], args[1], args[2], args[3]); diff --git a/net.c b/net.c index bc956cc..33fabd1 100644 --- a/net.c +++ b/net.c @@ -903,8 +903,7 @@ static SlirpState *slirp_lookup(Monitor *mon, const char *vlan, } } -void net_slirp_hostfwd_remove(Monitor *mon, const char *arg1, - const char *arg2, const char *arg3) +void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict) { struct in_addr host_addr = { .s_addr = INADDR_ANY }; int host_port; @@ -913,6 +912,9 @@ void net_slirp_hostfwd_remove(Monitor *mon, const char *arg1, SlirpState *s; int is_udp = 0; int err; + const char *arg1 = qdict_get_str(qdict, "arg1"); + const char *arg2 = qdict_get_str(qdict, "arg2"); + const char *arg3 = qdict_get_str(qdict, "arg3"); if (arg2) { s = slirp_lookup(mon, arg1, arg2); @@ -1022,11 +1024,13 @@ static void slirp_hostfwd(SlirpState *s, Monitor *mon, const char *redir_str, config_error(mon, "invalid host forwarding rule '%s'\n", redir_str); } -void net_slirp_hostfwd_add(Monitor *mon, const char *arg1, - const char *arg2, const char *arg3) +void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict) { const char *redir_str; SlirpState *s; + const char *arg1 = qdict_get_str(qdict, "arg1"); + const char *arg2 = qdict_get_str(qdict, "arg2"); + const char *arg3 = qdict_get_str(qdict, "arg3"); if (arg2) { s = slirp_lookup(mon, arg1, arg2); diff --git a/net.h b/net.h index e6fd3f8..706531a 100644 --- a/net.h +++ b/net.h @@ -137,10 +137,8 @@ int net_client_init(Monitor *mon, const char *device, const char *p); void net_client_uninit(NICInfo *nd); int net_client_parse(const char *str); void net_slirp_smb(const char *exported_dir); -void net_slirp_hostfwd_add(Monitor *mon, const char *arg1, - const char *arg2, const char *arg3); -void net_slirp_hostfwd_remove(Monitor *mon, const char *arg1, - const char *arg2, const char *arg3); +void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict); +void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict); void net_slirp_redir(const char *redir_str); void net_cleanup(void); void net_client_check(void); diff --git a/sysemu.h b/sysemu.h index a2ce843..7312bf2 100644 --- a/sysemu.h +++ b/sysemu.h @@ -204,8 +204,7 @@ void destroy_nic(dev_match_fn *match_fn, void *arg); void destroy_bdrvs(dev_match_fn *match_fn, void *arg); /* pci-hotplug */ -void pci_device_hot_add(Monitor *mon, const char *pci_addr, const char *type, - const char *opts); +void pci_device_hot_add(Monitor *mon, const QDict *qdict); void drive_hot_add(Monitor *mon, const QDict *qdict); void pci_device_hot_remove(Monitor *mon, const char *pci_addr); void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);