From patchwork Fri Apr 8 16:13:36 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: 8784531 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 0E12F9F659 for ; Fri, 8 Apr 2016 16:15:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F646202DD for ; Fri, 8 Apr 2016 16:15:51 +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 1203D2011D for ; Fri, 8 Apr 2016 16:15:50 +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 1aoZ2a-0006bG-Kp; Fri, 08 Apr 2016 16:13:48 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoZ2Z-0006ak-8k for xen-devel@lists.xenproject.org; Fri, 08 Apr 2016 16:13:47 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 37/18-07120-AB8D7075; Fri, 08 Apr 2016 16:13:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXitHRDpO6uG+z hBhO+sVl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkt914zFzzVrFi/+z5jA+NFuS5GTg4JAX+J ZT9mMIHYbAI6Ehfn7mTrYuTgEBFQkbi91wAkzCxQLPF1VR8riC0MVL711TVGEJsFqOTou51gr bwCLhKtl9tYIUbqSpzcvYkdxOYUcJU42PoALC4EVHPm9yVWiHpBiZMzn7BAzNeUaN3+mx3Clp do3jqbGaJeUaJ/3gOwcyQEuCX+dttPYOSfhaR7FpLuWUi6FzAyr2JUL04tKkst0jXWSyrKTM8 oyU3MzNE1NDDTy00tLk5MT81JTCrWS87P3cQIDD8GINjB2PHP6RCjJAeTkiivzin2cCG+pPyU yozE4oz4otKc1OJDjDIcHEoSvEevA+UEi1LTUyvSMnOAkQCTluDgURLh3QOS5i0uSMwtzkyHS J1iVJQS5z0FkhAASWSU5sG1waLvEqOslDAvI9AhQjwFqUW5mSWo8q8YxTkYlYR574JM4cnMK4 Gb/gpoMRPQ4gv8bCCLSxIRUlINjNyPT2n/0lFLZ5dyXV9sz/mq6RB/T65mWYz5kevca5/WJOp 83io8y/jTlGmlYkqftn3bHnRwghu3qlvSEtn/C2Yx5lnpHvmn+b6d5/lTd6HrJ3N12jpTRR+u nv//+96nbwOubbjGwrCXMYdxbuMHpmiJHx3/zF1vpFxzPR8hut/uWVqPuM/0dUosxRmJhlrMR cWJAKJI0/W5AgAA X-Env-Sender: prvs=89920a859=roger.pau@citrix.com X-Msg-Ref: server-8.tower-21.messagelabs.com!1460132023!8272430!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 45429 invoked from network); 8 Apr 2016 16:13:45 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-8.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 8 Apr 2016 16:13:45 -0000 X-IronPort-AV: E=Sophos;i="5.24,454,1454976000"; d="scan'208";a="345838101" From: Roger Pau Monne To: Date: Fri, 8 Apr 2016 18:13:36 +0200 Message-ID: <1460132019-23719-2-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.6.4 (Apple Git-63) In-Reply-To: <1460132019-23719-1-git-send-email-roger.pau@citrix.com> References: <1460132019-23719-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Wei Liu , Ian Jackson , Roger Pau Monne Subject: [Xen-devel] [PATCH v2 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é Acked-by: Wei Liu --- Cc: Ian Jackson Cc: 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);