From patchwork Fri May 20 17:45:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9129953 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 9222F60467 for ; Fri, 20 May 2016 17:47:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8763A27CAF for ; Fri, 20 May 2016 17:47:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B45227D73; Fri, 20 May 2016 17:47:56 +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 DE77327CAF for ; Fri, 20 May 2016 17:47:54 +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 1b3oUA-0008Ec-Gi; Fri, 20 May 2016 17:45:18 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b3oU8-0008EW-Vn for xen-devel@lists.xenproject.org; Fri, 20 May 2016 17:45:17 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 82/8B-05710-92D4F375; Fri, 20 May 2016 17:45:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXitHRDpK6mr32 4wTQri+9bJjM5MHoc/nCFJYAxijUzLym/IoE1Y82pDywF23QqrjUeYWlgfK/YxcjJISHgL3Hq 2CFWEJtFQFXidMtDdhCbTUBZ4mdnLxuILSKgLbH/3Wswm1lgBaPErIlKILawgJXEsXdLGbsYO Th4BfQlPj3MAwkLCSRLTHnbyAJi8woISpyc+YQFolVHYsHuT2wg5cwC0hLL/3GAhDkF7CVe39 nIBGKLCqhIXJnwlh1ijIJEx/RjTCDlEgLcEn+77Scw8s9CMnQWkqGzEIYuYGRexahRnFpUllq ka2iol1SUmZ5RkpuYmaNraGCsl5taXJyYnpqTmFSsl5yfu4kRGHoMQLCDcfVvp0OMkhxMSqK8 auL24UJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeJ96AeUEi1LTUyvSMnOAUQCTluDgURLhXesNl OYtLkjMLc5Mh0idYlSUEud1BUkIgCQySvPg2mCRd4lRVkqYlxHoECGegtSi3MwSVPlXjOIcjE rCvEdBpvBk5pXATX8FtJgJaPEtMRuQxSWJCCmpBsbqzoccfCaRc1s/b3E/5uW47zI/76cJNyd ++7hYaMmzdsHmlLtWbIazT/1P7V1fWide8Pb9buH7atN2T533mN/7rd2pugWdR9x0znnl86jf nN85jyM+Wt52uV/vNeMllYv0i2+wejkLfrVe9k7pvvl/D+ZfkaL5vEVRq1VYn70IWFOwVE1nk YkSS3FGoqEWc1FxIgAjZaT8twIAAA== X-Env-Sender: prvs=941dd85b8=wei.liu2@citrix.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1463766310!15035681!1 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.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6089 invoked from network); 20 May 2016 17:45:12 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-11.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 20 May 2016 17:45:12 -0000 X-IronPort-AV: E=Sophos;i="5.26,340,1459814400"; d="scan'208";a="355613774" Date: Fri, 20 May 2016 18:45:04 +0100 From: Wei Liu To: Ian Jackson Message-ID: <20160520174504.GF31272@citrix.com> References: <20160520163451.GB31272@citrix.com> <22335.15764.94991.14504@mariner.uk.xensource.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <22335.15764.94991.14504@mariner.uk.xensource.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-DLP: MIA1 Cc: Anthony PERARD , Xen-devel , Wei Liu , George Dunlap Subject: Re: [Xen-devel] [RFC] libxl hotplug / unplug emulated devices 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 On Fri, May 20, 2016 at 05:38:44PM +0100, Ian Jackson wrote: > Wei Liu writes ("[RFC] libxl hotplug / unplug emulated devices"): > > Recently I got a report on xen-users@ about xl network-attach not > > working for HVM guest. > > > > I try to use > > xl network-attach jessie-hvm 'bridge=xenbr0' > > and vif-bridge script complains that it can't add vifXX-emu to bridge. > > > > The underlying issue is that the vif spec provided defaults to > > emulated nic, but libxl only populates a pv nic but doesn't call out > > via QMP to QEMU to populate one. Note that this issue not only affects > > nic device but essentially all device types. > > Is it really sensible to offer emulated nic hotplug ? That'd be > presented to the guest as pci hotplug, I guess ? > > > I also experimented with block device: > > xl block-attach jessie-hvm 'phy:/dev/DATA/disk,hdb,w' > > and it succeed, only pv disk is populated though. > > That's what I would have expected. > > Maybe the fix should be that xl network-attach should default hotplug > nics to pv only. > Here is a patch to do this. :-) ---8<--- From 0a0a0ac76f825983bb13d70e46a59cabb05ed77b Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Fri, 20 May 2016 18:16:05 +0100 Subject: [PATCH for-4.7] libxl: nic type defaults to vif in hotplug for hvm guest We don't support plugging in emulated nic to a HVM guest. The "update_json" flag is only set when doing hotplug, so use that as an indicator in libxl__device_nic_add. The new hotplug flag to _setdefault function should be false in all other locations. This then requires saving nic type in JSON file, because we don't want the receiving end to recalculate the nic type. Signed-off-by: Wei Liu Acked-by: Ian Jackson --- tools/libxl/libxl.c | 6 +++--- tools/libxl/libxl_create.c | 3 ++- tools/libxl/libxl_dm.c | 3 ++- tools/libxl/libxl_internal.h | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index c39d745..62e9294 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -3319,7 +3319,7 @@ out: /******************************************************************************/ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, - uint32_t domid) + uint32_t domid, bool hotplug) { int rc; @@ -3358,7 +3358,7 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, case LIBXL_DOMAIN_TYPE_HVM: if (!nic->nictype) { if (libxl__device_model_version_running(gc, domid) == - LIBXL_DEVICE_MODEL_VERSION_NONE) + LIBXL_DEVICE_MODEL_VERSION_NONE || hotplug) nic->nictype = LIBXL_NIC_TYPE_VIF; else nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU; @@ -3411,7 +3411,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); + rc = libxl__device_nic_setdefault(gc, nic, domid, aodev->update_json); 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 5000bd0..7e57215 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -946,7 +946,8 @@ 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); + ret = libxl__device_nic_setdefault(gc, &d_config->nics[i], domid, + false); 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 4aff323a..65dceee 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1809,7 +1809,8 @@ 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); + ret = libxl__device_nic_setdefault(gc, &dm_config->nics[i], dm_domid, + false); if (ret) goto out; } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index c791418..fac5751 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1217,7 +1217,7 @@ _hidden int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk, uint32_t domid); _hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, - uint32_t domid); + uint32_t domid, bool hotplug); _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); @@ -4095,6 +4095,7 @@ static inline void libxl__update_config_nic(libxl__gc *gc, libxl_device_nic *src) { dst->devid = src->devid; + dst->nictype = src->nictype; libxl_mac_copy(CTX, &dst->mac, &src->mac); }