From patchwork Thu Sep 27 13:28:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 187361 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 0A6B12C00AF for ; Thu, 27 Sep 2012 23:30:28 +1000 (EST) Received: from localhost ([::1]:33852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THEAc-0000on-5s for incoming@patchwork.ozlabs.org; Thu, 27 Sep 2012 09:30:26 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THE8I-0005LI-6n for qemu-devel@nongnu.org; Thu, 27 Sep 2012 09:28:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THE8H-0003XK-46 for qemu-devel@nongnu.org; Thu, 27 Sep 2012 09:28:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THE8G-0003XB-SO for qemu-devel@nongnu.org; Thu, 27 Sep 2012 09:28:01 -0400 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.14.4/8.14.4) with ESMTP id q8RDS0S7024411 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 Sep 2012 09:28:00 -0400 Received: from localhost (ovpn-113-87.phx2.redhat.com [10.3.113.87]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8RDRx5o013122; Thu, 27 Sep 2012 09:27:59 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Thu, 27 Sep 2012 10:28:20 -0300 Message-Id: <1348752509-1142-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1348752509-1142-1-git-send-email-lcapitulino@redhat.com> References: <1348752509-1142-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 06/15] pci-assign: use monitor_handle_fd_param 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 From: Paolo Bonzini There is no need to open-code the choice between a file descriptor number or a named one. Just use monitor_handle_fd_param, which also takes care of printing the error message. Signed-off-by: Paolo Bonzini Signed-off-by: Luiz Capitulino Reviewed-by: Markus Armbruster --- hw/kvm/pci-assign.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index 05b93d9..7a0998c 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -579,15 +579,9 @@ static int get_real_device(AssignedDevice *pci_dev, uint16_t r_seg, snprintf(name, sizeof(name), "%sconfig", dir); if (pci_dev->configfd_name && *pci_dev->configfd_name) { - if (qemu_isdigit(pci_dev->configfd_name[0])) { - dev->config_fd = strtol(pci_dev->configfd_name, NULL, 0); - } else { - dev->config_fd = monitor_get_fd(cur_mon, pci_dev->configfd_name); - if (dev->config_fd < 0) { - error_report("%s: (%s) unkown", __func__, - pci_dev->configfd_name); - return 1; - } + dev->config_fd = monitor_handle_fd_param(cur_mon, pci_dev->configfd_name); + if (dev->config_fd < 0) { + return 1; } } else { dev->config_fd = open(name, O_RDWR);