From patchwork Tue Jun 7 11:24:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9160625 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 F33FC60467 for ; Tue, 7 Jun 2016 11:26:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2FDF25EF7 for ; Tue, 7 Jun 2016 11:26:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7B542793B; Tue, 7 Jun 2016 11:26:13 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 47EBD281D2 for ; Tue, 7 Jun 2016 11:26:12 +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 1bAF7F-00014V-LX; Tue, 07 Jun 2016 11:24:13 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAF7D-00013G-Qx for xen-devel@lists.xenproject.org; Tue, 07 Jun 2016 11:24:11 +0000 Received: from [193.109.254.147] by server-2.bemta-14.messagelabs.com id 95/89-02817-ADEA6575; Tue, 07 Jun 2016 11:24:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsXitHSDve7NdWH hBucOqVl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkrfj1hKdjBX9H/sYmpgfEfdxcjJ4eEgL/E 0x+fWUFsNgFliZ+dvWwgtoiAnkTTgeeMXYxcHMwCJxglnt57A5YQFrCWuL6hCcxmEVCRmD/5K TuIzSvgJDGreSszxFA5ifPHf4LZnALOEjuOPAOrEQKqWfb5OiOErSDRMf0YE0SvoMTJmU9YQG xmAQmJgy9eAPVyAM3hlvjbbT+BkW8WkqpZSKoWMDKtYtQoTi0qSy3SNTTQSyrKTM8oyU3MzNE 1NDTRy00tLk5MT81JTCrWS87P3cQIDCoGINjBeG6Z8yFGSQ4mJVHeh95h4UJ8SfkplRmJxRnx RaU5qcWHGGU4OJQkeFevBcoJFqWmp1akZeYAwxsmLcHBoyTCexYkzVtckJhbnJkOkTrFqCglz msPkhAASWSU5sG1wWLqEqOslDAvI9AhQjwFqUW5mSWo8q8YxTkYlYR5F4FM4cnMK4Gb/gpoMR PQ4mXXgkEWlyQipKQaGBvLawT2uLXE5JbN7/SzmnWaVVGMyT2vM6/ZUOLoXl6R3X+4eSZ/CdS y+3Rh2eU1mxIPhLmKK4ZV5F419xF8c0Qvp/Abz7bjVlYPyvYcOKoWWHVaYNdpbbG6Twfqnmrm 8POYx33PXfw1R4p79R8VpY+Hyov1Sx2XeP1f9/Hab8GXa0N3SYl/V2Ipzkg01GIuKk4EABll3 EWkAgAA X-Env-Sender: prvs=95970c4b2=wei.liu2@citrix.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1465298644!44282818!3 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4238 invoked from network); 7 Jun 2016 11:24:09 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-2.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 7 Jun 2016 11:24:09 -0000 X-IronPort-AV: E=Sophos;i="5.26,432,1459814400"; d="scan'208";a="365705405" From: Wei Liu To: Xen-devel Date: Tue, 7 Jun 2016 12:24:01 +0100 Message-ID: <1465298642-5356-3-git-send-email-wei.liu2@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1465298642-5356-1-git-send-email-wei.liu2@citrix.com> References: <1465298642-5356-1-git-send-email-wei.liu2@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Anthony PERARD , Wei Liu , Stefano Stabellini , Ian Jackson , Jan Beulich Subject: [Xen-devel] [PATCH 2/3] libxl: introduce libxl__qmp_query_cpus 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 It interrogates QEMU for the number of cpus. Signed-off-by: Wei Liu --- tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_qmp.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 38ec54d..5c22b97 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1794,6 +1794,9 @@ _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enabl _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk); /* Add a virtual CPU */ _hidden int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int index); +/* Query the number of CPUs */ +_hidden int libxl__qmp_query_cpus(libxl__gc *gc, int domid, + unsigned int *count); /* Start NBD server */ _hidden int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid, const char *host, const char *port); diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 3eb279a..b9de867 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -979,6 +979,25 @@ int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int idx) return qmp_run_command(gc, domid, "cpu-add", args, NULL, NULL); } +static int query_cpus_callback(libxl__qmp_handler *qmp, + const libxl__json_object *response, + void *opaque) +{ + unsigned int *count = opaque; + GC_INIT(qmp->ctx); + + *count = libxl__json_array_count(response); + + GC_FREE; + return 0; +} + +int libxl__qmp_query_cpus(libxl__gc *gc, int domid, unsigned int *count) +{ + return qmp_run_command(gc, domid, "query-cpus", NULL, + query_cpus_callback, count); +} + int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid, const char *host, const char *port) {