From patchwork Thu Apr 7 17:45:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 8775401 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D4BA09F36E for ; Thu, 7 Apr 2016 17:47:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D490220204 for ; Thu, 7 Apr 2016 17:47:57 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id D3F20201CD for ; Thu, 7 Apr 2016 17:47:56 +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 1aoE09-0008A0-9R; Thu, 07 Apr 2016 17:45:53 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoE07-00089U-Rc for xen-devel@lists.xenproject.org; Thu, 07 Apr 2016 17:45:51 +0000 Received: from [193.109.254.147] by server-6.bemta-14.messagelabs.com id 24/25-03497-FCC96075; Thu, 07 Apr 2016 17:45:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXitHRDpO65OWz hButnyFl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmf+3exFOzUrJjTrtrAuEqui5GTQ0LAX+LJ gdmsIDabgI7Exbk72boYOThEBFQkbu81AAkzCxRLfF3VB1YiLOAjcf3HGhYQmwWo5MGvU4wgN q+Ai8Te3buYIUbqSpzcvYkdZAyngKvEtjc8IGEhoJKPDV+hygUlTs58wgIxXlOidftvdghbXq J562xmiHpFif55D9ggRnJL3D49lXkCI/8sJO2zkLTPQtK+gJF5FaN6cWpRWWqRroVeUlFmekZ JbmJmjq6hoYlebmpxcWJ6ak5iUrFecn7uJkZg8DEAwQ7GjZOcDzFKcjApifIu72ALF+JLyk+p zEgszogvKs1JLT7EKMPBoSTBGzYbKCdYlJqeWpGWmQOMA5i0BAePkgjvKpA0b3FBYm5xZjpE6 hSjopQ4bxpIQgAkkVGaB9cGi71LjLJSwryMQIcI8RSkFuVmlqDKv2IU52BUEuZtB5nCk5lXAj f9FdBiJqDFF/jBFpckIqSkGhhrajZbZB1QvLZz1ouDCTlbk+a1JCf8aY3fe+HKJY3woqm3qwS tfdROXLaJevGY/8wGK9+8Gd3HZl+r078wn1dkQvwfl8Z4rjI5r4qSPfHvdCNeyloJvrokUinZ P43BZca3+sQX3oFPZnsstf5pv7LAmnXvrkKjbT5tayYY5NoWKGurnhVJ6VRiKc5INNRiLipOB ABip660uAIAAA== X-Env-Sender: prvs=898fe3ee9=roger.pau@citrix.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1460051148!36186950!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10779 invoked from network); 7 Apr 2016 17:45:50 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-9.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 7 Apr 2016 17:45:50 -0000 X-IronPort-AV: E=Sophos;i="5.24,449,1454976000"; d="scan'208";a="345585799" From: Roger Pau Monne To: Date: Thu, 7 Apr 2016 19:45:26 +0200 Message-ID: <1460051129-20817-2-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.6.4 (Apple Git-63) In-Reply-To: <1460051129-20817-1-git-send-email-roger.pau@citrix.com> References: <1460051129-20817-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Wei Liu , Ian Jackson , Roger Pau Monne Subject: [Xen-devel] [PATCH 1/4] libxl: set the device model version earlier in xenstore 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP So libxl doesn't have to pass the build info around just to get the device model used by the guest. This allows to simplify libxl__device_nic_setdefault. Signed-off-by: Roger Pau Monné Cc: Ian Jackson Cc: Wei Liu Acked-by: Wei Liu --- tools/libxl/libxl.c | 24 +++++++----------------- tools/libxl/libxl_create.c | 9 +++++++-- tools/libxl/libxl_dm.c | 3 +-- tools/libxl/libxl_internal.h | 3 +-- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 5cdc09e..d35fc33 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -3292,7 +3292,7 @@ out: /******************************************************************************/ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, - uint32_t domid, libxl_domain_build_info *info) + uint32_t domid) { int rc; @@ -3330,21 +3330,11 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, switch (libxl__domain_type(gc, domid)) { case LIBXL_DOMAIN_TYPE_HVM: if (!nic->nictype) { - if (info != NULL) { - /* Path taken at creation time. */ - if (info->device_model_version == - LIBXL_DEVICE_MODEL_VERSION_NONE) - nic->nictype = LIBXL_NIC_TYPE_VIF; - else - nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU; - } else { - /* Path taken when hot-adding a nic. */ - if (libxl__device_model_version_running(gc, domid) == - LIBXL_DEVICE_MODEL_VERSION_NONE) - nic->nictype = LIBXL_NIC_TYPE_VIF; - else - nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU; - } + if (libxl__device_model_version_running(gc, domid) == + LIBXL_DEVICE_MODEL_VERSION_NONE) + nic->nictype = LIBXL_NIC_TYPE_VIF; + else + nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU; } break; case LIBXL_DOMAIN_TYPE_PV: @@ -3394,7 +3384,7 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid, libxl_device_nic_init(&nic_saved); libxl_device_nic_copy(CTX, &nic_saved, nic); - rc = libxl__device_nic_setdefault(gc, nic, domid, NULL); + rc = libxl__device_nic_setdefault(gc, nic, domid); if (rc) goto out; front = flexarray_make(gc, 16, 1); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 4b02de9..24f168b 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -916,6 +916,12 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } + /* + * Set the dm version quite early so that libxl doesn't have to pass the + * build info around just to know if the domain has a device model or not. + */ + store_libxl_entry(gc, domid, &d_config->b_info); + for (i = 0; i < d_config->num_disks; i++) { ret = libxl__device_disk_setdefault(gc, &d_config->disks[i]); if (ret) { @@ -940,8 +946,7 @@ static void initiate_domain_create(libxl__egc *egc, * called libxl_device_nic_add when domcreate_launch_dm gets called, * but qemu needs the nic information to be complete. */ - ret = libxl__device_nic_setdefault(gc, &d_config->nics[i], domid, - &d_config->b_info); + ret = libxl__device_nic_setdefault(gc, &d_config->nics[i], domid); if (ret) { LOG(ERROR, "Unable to set nic defaults for nic %d", i); goto error_out; diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index eac5501..a12c90d 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1810,8 +1810,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc, * called libxl_device_nic_add at this point, but qemu needs * the nic information to be complete. */ - ret = libxl__device_nic_setdefault(gc, &dm_config->nics[i], dm_domid, - &dm_config->b_info); + ret = libxl__device_nic_setdefault(gc, &dm_config->nics[i], dm_domid); if (ret) goto out; } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 653c152..55896f8 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1206,8 +1206,7 @@ _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc, _hidden int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk); _hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, - uint32_t domid, - libxl_domain_build_info *info); + uint32_t domid); _hidden int libxl__device_vtpm_setdefault(libxl__gc *gc, libxl_device_vtpm *vtpm); _hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb); _hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb);