From patchwork Wed Jun 15 09:31:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9177921 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 0848E60831 for ; Wed, 15 Jun 2016 09:34:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDB9E2818B for ; Wed, 15 Jun 2016 09:34:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2EBB2821D; Wed, 15 Jun 2016 09:34:17 +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 8CAC52818B for ; Wed, 15 Jun 2016 09:34:17 +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 1bD7Az-0001tr-MU; Wed, 15 Jun 2016 09:31:57 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bD7Ax-0001t4-UL for xen-devel@lists.xenproject.org; Wed, 15 Jun 2016 09:31:56 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id F5/0A-24961-B8021675; Wed, 15 Jun 2016 09:31:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsXitHSDvW6XQmK 4wf5fJhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bfR9fZC6ZIVzy8co6xgXGSaBcjJ4eEgL/E kRP32UBsNgFliZ+dvWC2iICeRNOB54wgNrNAuUTn1s+sILawgJfEgZ5edhCbRUBVYuvMzWBxX gFniYNHmtghZspJnD/+kxnE5hRwkZh94yXQTA4OIaCaQ+tkQcJCAgoSHdOPMUG0CkqcnPmEBW KVhMTBFy+YIcZwS9w+PZV5AiPfLCRls5CULWBkWsWoUZxaVJZapGtoqJdUlJmeUZKbmJmja2h grJebWlycmJ6ak5hUrJecn7uJERhSDECwg3H1b6dDjJIcTEqivB5yieFCfEn5KZUZicUZ8UWl OanFhxhlODiUJHgnyAPlBItS01Mr0jJzgMENk5bg4FES4dUASfMWFyTmFmemQ6ROMSpKifOmg CQEQBIZpXlwbbCIusQoKyXMywh0iBBPQWpRbmYJqvwrRnEORiVh3hUgU3gy80rgpr8CWswEtN hmejzI4pJEhJRUA2N/9cHkmWfXf5HIdJTel/v+2M/7x1c4pnTyZCofSuLoOT7PbEu19vvL2W1 n4ktSnKvEFgTJLIvoOHg55MPRq4v+6txJC3ghevvSKe4UzfAl1RImjdKRrv8erk1qKM9d5Om6 Jdn8gHKw8qcL73RDouczM0265fRts+zNr7/uS5p++P979ZxS41QlluKMREMt5qLiRACqJyebo wIAAA== X-Env-Sender: prvs=967af9503=wei.liu2@citrix.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1465983104!19238295!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 3955 invoked from network); 15 Jun 2016 09:31:54 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-6.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 15 Jun 2016 09:31:54 -0000 X-IronPort-AV: E=Sophos;i="5.26,475,1459814400"; d="scan'208";a="367406696" From: Wei Liu To: Xen-devel Date: Wed, 15 Jun 2016 10:31:39 +0100 Message-ID: <1465983102-19308-3-git-send-email-wei.liu2@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1465983102-19308-1-git-send-email-wei.liu2@citrix.com> References: <1465983102-19308-1-git-send-email-wei.liu2@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Anthony PERARD , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH v3 2/5] libxl: factor out libxl__get_device_modlel_version 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 Factor out the logic to determine device model version to a function. It will be used later. Note that code now also checks if the stbudom field is actually set before trying to extract a value from it. No functional change. Signed-off-by: Wei Liu Reviewed-by: Dario Faggioli Reviewed-by: Anthony PERARD Acked-by: Ian Jackson --- Cc: Ian Jackson Cc: Anthony PERARD v3: new patch --- tools/libxl/libxl_create.c | 35 ++++++++++++++++++++++++----------- tools/libxl/libxl_internal.h | 5 +++++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 1b99472..45fd7bc 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -62,6 +62,28 @@ void libxl__rdm_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info) LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT; } +libxl_device_model_version +libxl__get_device_model_version(libxl__gc *gc, + const libxl_domain_build_info *b_info) +{ + libxl_device_model_version version = LIBXL_DEVICE_MODEL_VERSION_UNKNOWN; + + if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) { + if (!libxl_defbool_is_default(b_info->device_model_stubdomain) && + libxl_defbool_val(b_info->device_model_stubdomain)) { + version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; + } else { + version = libxl__default_device_model(gc); + } + } else { + version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN; + } + + assert(version != LIBXL_DEVICE_MODEL_VERSION_UNKNOWN); + + return version; +} + int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info) { @@ -80,17 +102,8 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, b_info->device_model_ssidref = SECINITSID_DOMDM; if (!b_info->device_model_version) { - if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) { - if (libxl_defbool_val(b_info->device_model_stubdomain)) { - b_info->device_model_version = - LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; - } else { - b_info->device_model_version = libxl__default_device_model(gc); - } - } else { - b_info->device_model_version = - LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN; - } + b_info->device_model_version = + libxl__get_device_model_version(gc, b_info); if (b_info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { const char *dm; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index e7ab85d..3958313 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1999,6 +1999,11 @@ _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid); /* Return the system-wide default device model */ _hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc); +/* Derive device model version from build info */ +_hidden libxl_device_model_version +libxl__get_device_model_version(libxl__gc *gc, + const libxl_domain_build_info *b_info); + #define DEVICE_MODEL_XS_PATH(gc, dm_domid, domid, fmt, _a...) \ libxl__sprintf(gc, "/local/domain/%u/device-model/%u" fmt, dm_domid, \ domid, ##_a)