From patchwork Thu Feb 11 01:49:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 45088 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 ozlabs.org (Postfix) with ESMTPS id C1B5CB6F08 for ; Thu, 11 Feb 2010 13:08:11 +1100 (EST) Received: from localhost ([127.0.0.1]:32791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfOSy-0005qQ-Rh for incoming@patchwork.ozlabs.org; Wed, 10 Feb 2010 21:07:40 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NfOCX-0006wP-Tp for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:50:42 -0500 Received: from [199.232.76.173] (port=57735 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfOCX-0006vb-8l for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:50:41 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NfOCU-0001HX-A9 for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:50:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21057) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NfOCT-0001HB-Ck for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:50:37 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1B1oaRH009016 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Feb 2010 20:50:36 -0500 Received: from localhost (vpn-10-105.rdu.redhat.com [10.11.10.105]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1B1oYBb011504; Wed, 10 Feb 2010 20:50:35 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 10 Feb 2010 23:49:55 -0200 Message-Id: <1265853007-27300-10-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1265853007-27300-1-git-send-email-lcapitulino@redhat.com> References: <1265853007-27300-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: armbru@redhat.com Subject: [Qemu-devel] [PATCH 09/21] Monitor: Convert pci_device_hot_add() to cmd_new_ret() 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 Signed-off-by: Luiz Capitulino --- hw/pci-hotplug.c | 16 +++++++++++----- qemu-monitor.hx | 2 +- sysemu.h | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 0fb96f0..6cc70d5 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -254,7 +254,7 @@ void pci_device_hot_add_print(Monitor *mon, const QObject *data) * * { "domain": 0, "bus": 0, "slot": 5, "function": 0 } */ -void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data) +int pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data) { PCIDevice *dev = NULL; const char *pci_addr = qdict_get_str(qdict, "pci_addr"); @@ -273,20 +273,26 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data) if (!strcmp(pci_addr, "auto")) pci_addr = NULL; - if (strcmp(type, "nic") == 0) + if (strcmp(type, "nic") == 0) { dev = qemu_pci_hot_add_nic(mon, pci_addr, opts); - else if (strcmp(type, "storage") == 0) + } else if (strcmp(type, "storage") == 0) { dev = qemu_pci_hot_add_storage(mon, pci_addr, opts); - else + } else { monitor_printf(mon, "invalid type: %s\n", type); + return -1; + } if (dev) { *ret_data = qobject_from_jsonf("{ 'domain': 0, 'bus': %d, 'slot': %d, " "'function': %d }", pci_bus_num(dev->bus), PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); - } else + } else { monitor_printf(mon, "failed to add %s\n", opts); + return -1; + } + + return 0; } #endif diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 6e84f76..2831055 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -857,7 +857,7 @@ ETEXI .params = "auto|[[:]:] nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", .help = "hot-add PCI device", .user_print = pci_device_hot_add_print, - .mhandler.cmd_new = pci_device_hot_add, + .cmd_new_ret = pci_device_hot_add, }, #endif diff --git a/sysemu.h b/sysemu.h index 9c3b281..d41a338 100644 --- a/sysemu.h +++ b/sysemu.h @@ -213,7 +213,7 @@ DriveInfo *add_init_drive(const char *opts); /* pci-hotplug */ void pci_device_hot_add_print(Monitor *mon, const QObject *data); -void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data); +int pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data); 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,