From patchwork Tue Aug 22 09:49:08 2017 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: 9914649 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 96DF6603FF for ; Tue, 22 Aug 2017 09:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A759928856 for ; Tue, 22 Aug 2017 09:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C2252885E; Tue, 22 Aug 2017 09:51:53 +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 0178128866 for ; Tue, 22 Aug 2017 09:51:53 +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 1dk5p5-0006HB-DN; Tue, 22 Aug 2017 09:50:11 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dk5p4-0006F4-I4 for xen-devel@lists.xenproject.org; Tue, 22 Aug 2017 09:50:10 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 04/F0-01862-15EFB995; Tue, 22 Aug 2017 09:50:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRWlGSWpSXmKPExsXitHRDpG7gv9m RBi8/8Ft83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBn7rm5mLbjrUtE0X6yBsdu4i5GTQ0LAX2LF grXMIDabgI7Exbk72boYOThEBFQkbu816GLk4mAWWMMocX7OH3aQGmEBB4k7rz6D1bMIqEos/ /wSLM4rYCnx9Fo3E8RMPYm3E18wgticAlYSh/c+AbOFgGo2fvzJClEvKHFy5hMWEJtZQFOidf tvdghbXqJ562xmiHpFif55D9gmMPLNQtIyC0nLLCQtCxiZVzFqFKcWlaUW6Rob6CUVZaZnlOQ mZuboGhoY6+WmFhcnpqfmJCYV6yXn525iBIZaPQMD4w7GzhN+hxglOZiURHknf58dKcSXlJ9S mZFYnBFfVJqTWnyIUYaDQ0mCl+0vUE6wKDU9tSItMwcY9DBpCQ4eJRHex3+A0rzFBYm5xZnpE KlTjLocHTN+fmMSYsnLz0uVEuf9AVIkAFKUUZoHNwIWgZcYZaWEeRkZGBiEeApSi3IzS1DlXz GKczAqCfO+AJnCk5lXArfpFdARTEBHGLZOAzmiJBEhJdXAKPLU8k7G8v2POh2Srd8lOtzS7FS PXmtVderJyrkcqlM57u565F4vtMBwhW/F9z1BR4/GLOy/4dn9hFWf73jbkrm3fbOl1tlc9TOY E7e1LKhQ7ufL85tOFml8ns9wuHGn+Jwd3y4m2e2zL9jwQ/vXxTvebmvmdW+xCg6oN5rvumX6H vFDv9N1apRYijMSDbWYi4oTAbucN2y7AgAA X-Env-Sender: prvs=400f1e73e=roger.pau@citrix.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1503395402!111036246!5 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: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63816 invoked from network); 22 Aug 2017 09:50:09 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-3.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 22 Aug 2017 09:50:09 -0000 X-IronPort-AV: E=Sophos;i="5.41,411,1498521600"; d="scan'208";a="436366303" From: Roger Pau Monne To: Date: Tue, 22 Aug 2017 10:49:08 +0100 Message-ID: <20170822094920.70151-8-roger.pau@citrix.com> X-Mailer: git-send-email 2.11.0 (Apple Git-81) In-Reply-To: <20170822094920.70151-1-roger.pau@citrix.com> References: <20170822094920.70151-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Wei Liu , boris.ostrovsky@oracle.com, Roger Pau Monne , Ian Jackson Subject: [Xen-devel] [PATCH 07/19] libxl: add PVH support to domain creation 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 Remove the device model "none" support from domain creation and introduce support for PVH. This requires changing some of the HVM checks to be applied for both HVM and PVH. Signed-off-by: Roger Pau Monné --- Cc: Ian Jackson Cc: Wei Liu --- tools/libxl/libxl_create.c | 69 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 75e85f8086..3988944994 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -35,7 +35,7 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, return ERROR_INVAL; } - if (c_info->type == LIBXL_DOMAIN_TYPE_HVM) { + if (c_info->type != LIBXL_DOMAIN_TYPE_PV) { libxl_defbool_setdefault(&c_info->hap, true); libxl_defbool_setdefault(&c_info->oos, true); } @@ -65,7 +65,8 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, int i; if (b_info->type != LIBXL_DOMAIN_TYPE_HVM && - b_info->type != LIBXL_DOMAIN_TYPE_PV) { + b_info->type != LIBXL_DOMAIN_TYPE_PV && + b_info->type != LIBXL_DOMAIN_TYPE_PVH) { LOG(ERROR, "invalid domain type"); return ERROR_INVAL; } @@ -120,8 +121,6 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, b_info->u.hvm.bios = LIBXL_BIOS_TYPE_ROMBIOS; break; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: b_info->u.hvm.bios = LIBXL_BIOS_TYPE_SEABIOS; break; - case LIBXL_DEVICE_MODEL_VERSION_NONE: - break; default: LOG(ERROR, "unknown device model version"); return ERROR_INVAL; @@ -141,8 +140,6 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, return ERROR_INVAL; } break; - case LIBXL_DEVICE_MODEL_VERSION_NONE: - break; default:abort(); } @@ -222,10 +219,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, b_info->u.hvm.mmio_hole_memkb = 0; if (b_info->u.hvm.vga.kind == LIBXL_VGA_INTERFACE_TYPE_UNKNOWN) { - if (b_info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_NONE) - b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_NONE; - else - b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_CIRRUS; + b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_CIRRUS; } if (!b_info->u.hvm.hdtype) @@ -259,12 +253,6 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, break; } break; - case LIBXL_DEVICE_MODEL_VERSION_NONE: - if (b_info->u.hvm.vga.kind != LIBXL_VGA_INTERFACE_TYPE_NONE) { - LOG(ERROR, - "guests without a device model cannot have an emulated video card"); - return ERROR_INVAL; - } b_info->video_memkb = 0; break; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: @@ -401,6 +389,8 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, b_info->u.pv.cmdline = NULL; } break; + case LIBXL_DOMAIN_TYPE_PVH: + break; default: LOG(ERROR, "invalid domain type %s in create info", libxl_domain_type_to_string(b_info->type)); @@ -519,6 +509,17 @@ int libxl__domain_build(libxl__gc *gc, } break; + case LIBXL_DOMAIN_TYPE_PVH: + ret = libxl__build_hvm(gc, domid, d_config, state); + if (ret) + goto out; + + vments = libxl__calloc(gc, 3, sizeof(char *)); + vments[0] = "start_time"; + vments[1] = GCSPRINTF("%lu.%02d", start_time.tv_sec, + (int)start_time.tv_usec/10000); + + break; default: ret = ERROR_INVAL; goto out; @@ -553,7 +554,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, } flags = 0; - if (info->type == LIBXL_DOMAIN_TYPE_HVM) { + if (info->type != LIBXL_DOMAIN_TYPE_PV) { flags |= XEN_DOMCTL_CDF_hvm_guest; flags |= libxl_defbool_val(info->hap) ? XEN_DOMCTL_CDF_hap : 0; flags |= libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off; @@ -880,7 +881,7 @@ static void initiate_domain_create(libxl__egc *egc, /* If target_memkb is smaller than max_memkb, the subsequent call * to libxc when building HVM domain will enable PoD mode. */ - pod_enabled = (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM) && + pod_enabled = (d_config->c_info.type != LIBXL_DOMAIN_TYPE_PV) && (d_config->b_info.target_memkb < d_config->b_info.max_memkb); /* We cannot have PoD and PCI device assignment at the same time @@ -889,7 +890,7 @@ static void initiate_domain_create(libxl__egc *egc, * guest. To stay on the safe side, we disable PCI device * assignment when PoD is enabled. */ - if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM && + if (d_config->c_info.type != LIBXL_DOMAIN_TYPE_PV && d_config->num_pcidevs && pod_enabled) { ret = ERROR_INVAL; LOGD(ERROR, domid, @@ -928,18 +929,20 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } - if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM && + if (d_config->c_info.type != LIBXL_DOMAIN_TYPE_PV && (libxl_defbool_val(d_config->b_info.nested_hvm) && - (libxl_defbool_val(d_config->b_info.u.hvm.altp2m) || + ((d_config->c_info.type != LIBXL_DOMAIN_TYPE_HVM && + libxl_defbool_val(d_config->b_info.u.hvm.altp2m)) || (d_config->b_info.altp2m != LIBXL_ALTP2M_MODE_DISABLED)))) { ret = ERROR_INVAL; LOGD(ERROR, domid, "nestedhvm and altp2mhvm cannot be used together"); goto error_out; } - if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM && - (libxl_defbool_val(d_config->b_info.u.hvm.altp2m) || - (d_config->b_info.altp2m != LIBXL_ALTP2M_MODE_DISABLED)) && + if (((d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM && + libxl_defbool_val(d_config->b_info.u.hvm.altp2m)) || + (d_config->c_info.type != LIBXL_DOMAIN_TYPE_PV && + d_config->b_info.altp2m != LIBXL_ALTP2M_MODE_DISABLED)) && pod_enabled) { ret = ERROR_INVAL; LOGD(ERROR, domid, "Cannot enable PoD and ALTP2M at the same time"); @@ -1122,7 +1125,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, crs->domid = domid; crs->send_back_fd = dcs->send_back_fd; crs->recv_fd = restore_fd; - crs->hvm = (info->type == LIBXL_DOMAIN_TYPE_HVM); + crs->hvm = (info->type != LIBXL_DOMAIN_TYPE_PV); crs->callback = libxl__colo_restore_setup_done; libxl__colo_restore_setup(egc, crs); break; @@ -1203,6 +1206,12 @@ static void domcreate_stream_done(libxl__egc *egc, vments[i++] = (char *) state->pv_cmdline; } break; + case LIBXL_DOMAIN_TYPE_PVH: + vments = libxl__calloc(gc, 3, sizeof(char *)); + vments[0] = "start_time"; + vments[1] = GCSPRINTF("%lu.%02d", start_time.tv_sec, + (int)start_time.tv_usec/10000); + break; default: ret = ERROR_INVAL; goto out; @@ -1367,12 +1376,6 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, libxl__device_console_add(gc, domid, &console, state, &device); libxl__device_console_dispose(&console); - if (d_config->b_info.device_model_version == - LIBXL_DEVICE_MODEL_VERSION_NONE) { - domcreate_devmodel_started(egc, &dcs->sdss.dm, 0); - return; - } - libxl_device_vkb_init(&vkb); libxl__device_vkb_add(gc, domid, &vkb); libxl_device_vkb_dispose(&vkb); @@ -1394,6 +1397,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, return; } case LIBXL_DOMAIN_TYPE_PV: + case LIBXL_DOMAIN_TYPE_PVH: { libxl__device_console console; libxl__device device; @@ -1700,8 +1704,7 @@ static void domain_soft_reset_cb(libxl__egc *egc, goto error; } - if (cdcs->dcs.guest_config->b_info.device_model_version != - LIBXL_DEVICE_MODEL_VERSION_NONE) { + if (cdcs->dcs.guest_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) { savefile = GCSPRINTF(LIBXL_DEVICE_MODEL_SAVE_FILE".%d", dds->domid); restorefile = GCSPRINTF(LIBXL_DEVICE_MODEL_RESTORE_FILE".%d", dds->domid);