From patchwork Fri Apr 8 16:13:37 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: 8784661 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 01FD4C0553 for ; Fri, 8 Apr 2016 16:19:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 168ED202DD for ; Fri, 8 Apr 2016 16:19:19 +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 2C3702027D for ; Fri, 8 Apr 2016 16:19:18 +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 1aoZ5t-0007Tr-NS; Fri, 08 Apr 2016 16:17:13 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoZ5s-0007TU-G2 for xen-devel@lists.xenproject.org; Fri, 08 Apr 2016 16:17:12 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 66/EA-09532-789D7075; Fri, 08 Apr 2016 16:17:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXitHSDvW7rTfZ wg439Khbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bZNy4FnWoVT65MYG1gvCTbxcjJISHgL/Fv XTMriM0moCNxce5Oti5GDg4RARWJ23sNQMLMAsUSX1f1gZUIC8RLrN52lBHEZgEqaVk6iwXE5 hVwkVg/dSsrxEhdiZO7N7GD2JwCrhIHWx+AxYWAas78vsQKUS8ocXLmExaI+ZoSrdt/s0PY8h LNW2czQ9QrSvTPewB2joQAt8TfbvsJjPyzkHTPQtI9C0n3AkbmVYzqxalFZalFukZ6SUWZ6Rk luYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBwccABDsYl/11OsQoycGkJMobeIM9XIgvKT+l MiOxOCO+qDQntfgQowwHh5IEby1ITrAoNT21Ii0zBxgHMGkJDh4lEV5DkDRvcUFibnFmOkTqF KOilDivM0hCACSRUZoH1waLvUuMslLCvIxAhwjxFKQW5WaWoMq/YhTnYFQS5p0GMoUnM68Ebv oroMVMQIsv8LOBLC5JREhJNTDOFHQ01VBa/ejB1LL71hvXed68qcTwpkCt3e2q7uTVczMnGPl t2zSDYVqVQPfzKbkdnzfnmezNnZ9nvV/hwy/u2dyb/xc9mHe0Wz/1z36fyC+2d88IfzHbM6Op 481kNZ332/UvfNtQb6sRebJUnv2/98M82WepF/KKPJevl/u365321tMqjvt+KbEUZyQaajEXF ScCAGlWEg24AgAA X-Env-Sender: prvs=89920a859=roger.pau@citrix.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1460132228!7785330!1 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.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16949 invoked from network); 8 Apr 2016 16:17:09 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-3.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 8 Apr 2016 16:17:09 -0000 X-IronPort-AV: E=Sophos;i="5.24,454,1454976000"; d="scan'208";a="352537925" From: Roger Pau Monne To: Date: Fri, 8 Apr 2016 18:13:37 +0200 Message-ID: <1460132019-23719-3-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 2/4] libxl: set the backend type to Qdisk for CDROM devices on DM HVM guests 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 This is needed because the cd-{insert/eject} functions are not prepared to deal with blkback, which would be used by default if no backend was specified. 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 | 2 +- tools/libxl/libxl_internal.h | 3 ++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index d35fc33..9d785a4 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2301,7 +2301,8 @@ int libxl_devid_to_device_vtpm(libxl_ctx *ctx, /******************************************************************************/ -int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk) +int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk, + uint32_t domid) { int rc; @@ -2312,6 +2313,19 @@ int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk) rc = libxl__resolve_domid(gc, disk->backend_domname, &disk->backend_domid); if (rc < 0) return rc; + /* Force Qdisk backend for CDROM devices of guests with a device model. */ + if (disk->is_cdrom != 0 && + libxl__domain_type(gc, domid) == LIBXL_DOMAIN_TYPE_HVM && + libxl__device_model_version_running(gc, domid) != + LIBXL_DEVICE_MODEL_VERSION_NONE) { + if (!(disk->backend == LIBXL_DISK_BACKEND_QDISK || + disk->backend == LIBXL_DISK_BACKEND_UNKNOWN)) { + LOG(ERROR, "Backend for CD devices on HVM guests must be Qdisk"); + return ERROR_FAIL; + } + disk->backend = LIBXL_DISK_BACKEND_QDISK; + } + rc = libxl__device_disk_set_backend(gc, disk); return rc; } @@ -2427,7 +2441,7 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid, } } - rc = libxl__device_disk_setdefault(gc, disk); + rc = libxl__device_disk_setdefault(gc, disk, domid); if (rc) goto out; front = flexarray_make(gc, 16, 1); @@ -2869,7 +2883,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk, disk_empty.vdev = libxl__strdup(NOGC, disk->vdev); disk_empty.pdev_path = libxl__strdup(NOGC, ""); disk_empty.is_cdrom = 1; - libxl__device_disk_setdefault(gc, &disk_empty); + libxl__device_disk_setdefault(gc, &disk_empty, domid); libxl_domain_type type = libxl__domain_type(gc, domid); if (type == LIBXL_DOMAIN_TYPE_INVALID) { @@ -2910,7 +2924,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk, goto out; } - rc = libxl__device_disk_setdefault(gc, disk); + rc = libxl__device_disk_setdefault(gc, disk, domid); if (rc) goto out; if (!disk->pdev_path) { @@ -3173,7 +3187,7 @@ void libxl__device_disk_local_initiate_attach(libxl__egc *egc, disk->script = libxl__strdup(gc, in_disk->script); disk->vdev = NULL; - rc = libxl__device_disk_setdefault(gc, disk); + rc = libxl__device_disk_setdefault(gc, disk, LIBXL_TOOLSTACK_DOMID); if (rc) goto out; libxl__prepare_ao_device(ao, &dls->aodev); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 24f168b..1a57907 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -923,7 +923,7 @@ static void initiate_domain_create(libxl__egc *egc, 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]); + ret = libxl__device_disk_setdefault(gc, &d_config->disks[i], domid); if (ret) { LOG(ERROR, "Unable to set disk defaults for disk %d", i); goto error_out; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 55896f8..47aca76 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1204,7 +1204,8 @@ _hidden int libxl__domain_create_info_setdefault(libxl__gc *gc, _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info); _hidden int libxl__device_disk_setdefault(libxl__gc *gc, - libxl_device_disk *disk); + libxl_device_disk *disk, + uint32_t domid); _hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, uint32_t domid); _hidden int libxl__device_vtpm_setdefault(libxl__gc *gc, libxl_device_vtpm *vtpm);