From patchwork Wed Aug 17 17:19:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9286223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D575260839 for ; Wed, 17 Aug 2016 17:21:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6CEE294AC for ; Wed, 17 Aug 2016 17:21:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB7FC294CF; Wed, 17 Aug 2016 17:21:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5BD14294AC for ; Wed, 17 Aug 2016 17:21:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ba4Uf-0000Ru-Pa; Wed, 17 Aug 2016 17:19:09 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ba4Ue-0000Qg-Fl for xen-devel@lists.xenproject.org; Wed, 17 Aug 2016 17:19:08 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 1F/96-24990-B8C94B75; Wed, 17 Aug 2016 17:19:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLIsWRWlGSWpSXmKPExsXiVRvkqNs1Z0u 4wZZj1hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aiFyfYC05IV9w6tpapgfGHaBcjF4eQwExG iafPDjCBOCwCa1gleg/vZwZxJAQusUqcWLgGyOEEcmIk/v5/zwJhl0ksXXORHcQWElCRuLl9F RPEqDlMEsfOrmYFSQgL6EkcOfoDqIgDyA6XuNQvAhJmEzCQeLNjL1iJiICSxL1Vk5lAbGaBCo kVL2+A2SwCqhKfPt4Hs3kFvCX6dh8D28sp4CNxa/VvFoi93hKHJ/ewgdiiAnISKy+3sELUC0q cnPmEBWQts4CmxPpd+hDj5SW2v53DPIFRZBaSqlkIVbOQVC1gZF7FqF6cWlSWWqRrppdUlJme UZKbmJmja2hgqpebWlycmJ6ak5hUrJecn7uJERj8DECwg3Fqg/MhRkkOJiVR3jvVW8KF+JLyU yozEosz4otKc1KLDzFqcHAITDg7dzqTFEtefl6qkgSv2mygOsGi1PTUirTMHGB8wpRKcPAoif CygqR5iwsSc4sz0yFSpxh1ObZMvbeWSQhshpQ477NZQEUCIEUZpXlwI2Cp4hKjrJQwLyPQgUI 8BalFuZklqPKvGMU5GJWEefVBVvFk5pXAbXoFdAQT0BG8/GBHlCQipKQaGOc+EXwX2ruowO5i GUfd+nPOSYI3qz1szry7nTY3bbJt/t1rlZ2JBabfvofPPnLwqdnfnfIWudJrnhzLdvBud78Ux GMuvPzg4e9TK39qq3BfYvynGm0f0zQ9/M662e+EVNd83V5ukJlZVBogX94yd9mRgHVfau0KNx 588pV1jWnE6/Mfnrw0m6rEUpyRaKjFXFScCAAhStOYEAMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1471454346!55051631!1 X-Originating-IP: [74.125.82.65] X-SpamReason: No, hits=0.2 required=7.0 tests=RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56325 invoked from network); 17 Aug 2016 17:19:06 -0000 Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by server-4.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Aug 2016 17:19:06 -0000 Received: by mail-wm0-f65.google.com with SMTP id i138so26180817wmf.3 for ; Wed, 17 Aug 2016 10:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=OxsMjxRXe5LjdskIujqXMfx4sx9v9ouVcJCuB42PMgE=; b=HIb85afaXyVhVl0tdCUJo7U3zSi+I5xEJu9cXj37bQfebPJAOHz7qtwFRaNlSOHGEh 2e/8Mz3re8dKgEYRexNrQcB15km8k7NyrxZa7+JfjIRjX52bsZ1Xsd4Ejy78y74ftNPa Ejbop09dL6vsRUds5e+X7qkagW7kMSaGESfR8gHodaP/kq1ZRugC+FU/s8ipEn5P07FJ zf50X9lQWTQiakEZwnXNzu3VJiTAHkHf4Hf+LzEa9JJpajMf3s0Cnm9+gr3s6f4Dn2uX +c2lu7kBSE63oz0JzYQXT4kkV+tjU5NRPDp3LJcO7brSEzYskBP7tolF0PO520zIC0xy ZqFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=OxsMjxRXe5LjdskIujqXMfx4sx9v9ouVcJCuB42PMgE=; b=KP/ygtxa5E+2XOd5+9IoR6lJJ95FDHS7+d2MKL4vJzq6JuHGXv/5d3+QskRAMXxtsn vvdANq6gjy3q2SaZbh1efReTxLj0PGU7BmF7+eCSVcQxkY/zzRqEvOas73EOw+2+LAZK N52cvDDP4FqBkzGlTp+v7uSsxh1aIwS6NYg9XW8f9HswYIMu9ddUW39Yr5pDTYc4ZGLu gTtZokdPvBvSe74bK1iJCHrs4voHE4uieZXDQEtsDm2+LIASyAPRsJOxXIbX3jTL84Ty Cc9T2+/WdFnwKcRKZuWCCDY4bB5QmdkKmgejq3wqwfnSo74fIdTf2lsnwyQEOniRS3sd ucjw== X-Gm-Message-State: AEkooutfa8PNi/37KjFov9h+w8aaz36SfWpoKwR27Lsf5dE9943LEHNx67jnqdmFpm6asg== X-Received: by 10.28.58.7 with SMTP id h7mr27202655wma.35.1471454346557; Wed, 17 Aug 2016 10:19:06 -0700 (PDT) Received: from Solace.fritz.box (net-2-32-14-104.cust.vodafonedsl.it. [2.32.14.104]) by smtp.gmail.com with ESMTPSA id g1sm23378909wjy.5.2016.08.17.10.19.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Aug 2016 10:19:05 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Wed, 17 Aug 2016 19:19:04 +0200 Message-ID: <147145434473.25877.8095947074334048832.stgit@Solace.fritz.box> In-Reply-To: <147145358844.25877.7490417583264534196.stgit@Solace.fritz.box> References: <147145358844.25877.7490417583264534196.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Wei Liu , Ian Jackson Subject: [Xen-devel] [PATCH 13/24] libxc: improve error handling of xc Credit1 and Credit2 helpers X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In fact, libxc wrappers should, on error, set errno and return -1. Signed-off-by: Dario Faggioli Acked-by: Wei Liu --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu --- tools/libxc/xc_csched.c | 27 +++++++++++++++------------ tools/libxc/xc_csched2.c | 15 +++++++++------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/tools/libxc/xc_csched.c b/tools/libxc/xc_csched.c index bf03bfc..139fc16 100644 --- a/tools/libxc/xc_csched.c +++ b/tools/libxc/xc_csched.c @@ -37,7 +37,10 @@ xc_sched_credit_domain_set( domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putinfo; domctl.u.scheduler_op.u.credit = *sdom; - return do_domctl(xch, &domctl); + if ( do_domctl(xch, &domctl) ) + return -1; + + return 0; } int @@ -47,18 +50,18 @@ xc_sched_credit_domain_get( struct xen_domctl_sched_credit *sdom) { DECLARE_DOMCTL; - int err; domctl.cmd = XEN_DOMCTL_scheduler_op; domctl.domain = (domid_t) domid; domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT; domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getinfo; - err = do_domctl(xch, &domctl); - if ( err == 0 ) - *sdom = domctl.u.scheduler_op.u.credit; + if ( do_domctl(xch, &domctl) ) + return -1; + + *sdom = domctl.u.scheduler_op.u.credit; - return err; + return 0; } int @@ -67,7 +70,6 @@ xc_sched_credit_params_set( uint32_t cpupool_id, struct xen_sysctl_credit_schedule *schedule) { - int rc; DECLARE_SYSCTL; sysctl.cmd = XEN_SYSCTL_scheduler_op; @@ -77,11 +79,12 @@ xc_sched_credit_params_set( sysctl.u.scheduler_op.u.sched_credit = *schedule; - rc = do_sysctl(xch, &sysctl); + if ( do_sysctl(xch, &sysctl) ) + return -1; *schedule = sysctl.u.scheduler_op.u.sched_credit; - return rc; + return 0; } int @@ -90,7 +93,6 @@ xc_sched_credit_params_get( uint32_t cpupool_id, struct xen_sysctl_credit_schedule *schedule) { - int rc; DECLARE_SYSCTL; sysctl.cmd = XEN_SYSCTL_scheduler_op; @@ -98,9 +100,10 @@ xc_sched_credit_params_get( sysctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT; sysctl.u.scheduler_op.cmd = XEN_SYSCTL_SCHEDOP_getinfo; - rc = do_sysctl(xch, &sysctl); + if ( do_sysctl(xch, &sysctl) ) + return -1; *schedule = sysctl.u.scheduler_op.u.sched_credit; - return rc; + return 0; } diff --git a/tools/libxc/xc_csched2.c b/tools/libxc/xc_csched2.c index 5b62a5f..12c95e6 100644 --- a/tools/libxc/xc_csched2.c +++ b/tools/libxc/xc_csched2.c @@ -37,7 +37,10 @@ xc_sched_credit2_domain_set( domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putinfo; domctl.u.scheduler_op.u.credit2 = *sdom; - return do_domctl(xch, &domctl); + if ( do_domctl(xch, &domctl) ) + return -1; + + return 0; } int @@ -47,18 +50,18 @@ xc_sched_credit2_domain_get( struct xen_domctl_sched_credit2 *sdom) { DECLARE_DOMCTL; - int err; domctl.cmd = XEN_DOMCTL_scheduler_op; domctl.domain = (domid_t) domid; domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT2; domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getinfo; - err = do_domctl(xch, &domctl); - if ( err == 0 ) - *sdom = domctl.u.scheduler_op.u.credit2; + if ( do_domctl(xch, &domctl) ) + return -1; + + *sdom = domctl.u.scheduler_op.u.credit2; - return err; + return 0; } int