From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853392; cv=none; d=zohomail.com; s=zohoarc; b=jhLmzCACvMYRP/hBM1cV4sNfhGw+tzJHG+ge4FXbGY/R6p/yCSA/3ytbe+ZX0DNDII0SDtU1hpm25Nh6k7q6G9XI+U7+kxZPDXINTWuzH1LL2eO+tt/o2zVz9JAiJZQdP5skgvgHfhWxPdwaQrTYNcrcVLiTxfCCQhk9ViWskT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853392; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y63NCLIHxjj8BP4Xs3EPNGxMJKsqwIK/ULA13gyh9ao=; b=FID+5O5dwp3x0VtsJ3ZXL7KOtUmcojLrL5Yz6H/zcYPDYk429THvuFrgF0K7ZJojU4mWFdIHfNjWAiHsSZZeT107SUFKZTSa9iRVIPXKlIBcUYB+R0JjpAYygxNABHjYjecowXlI63iC8S4XpRwNVYK3myTJYgKhcWpFBlm0yfo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853392349477.8088455512092; Mon, 18 May 2020 18:56:32 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarU2-00008q-0q; Tue, 19 May 2020 01:55:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarU0-00008l-Kv for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:55:52 +0000 Received: from mail-qt1-x843.google.com (unknown [2607:f8b0:4864:20::843]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dd8b8de2-9973-11ea-b9cf-bc764e2007e4; Tue, 19 May 2020 01:55:50 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id z18so9945223qto.2 for ; Mon, 18 May 2020 18:55:50 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:55:48 -0700 (PDT) X-Inumbo-ID: dd8b8de2-9973-11ea-b9cf-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y63NCLIHxjj8BP4Xs3EPNGxMJKsqwIK/ULA13gyh9ao=; b=qhM4TcnwPR1z6ZqEH726/8IqkiIt05I778AInSF2R9Li+XAu2lZQ6aQc6e7qRus2Dg hVWPSFIOvL8OidZwX9cF8XaLrh0QqMYNtbiQ500czIMn/E51Yxn+YpKAPv7htylJ6FTw sB6nVaxnEt73V/5np44lGRQe/omkFbB0XHLkEDDJbGW01A6Dp98326iIWRjO1lXGff5j 1IiM3+IZiqKuHRt3absnwz6rboTVXCj3I8yZkEFFhtB6N4Bn35HBpYDhbhJjhJlx74eF Kfyb9a50ZdNICE4r2gB/GndIjtizCqQQ10ovk/uFtNz7FFtoGkCK2BR9DNQEuyT1XBsG Rvgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y63NCLIHxjj8BP4Xs3EPNGxMJKsqwIK/ULA13gyh9ao=; b=tFWBTw1teYDUOl9Ulu3cmMk+Qt7/NDpsKifaZmLeSEUvulsM4W6hW5n97ytQjT9WKM QcNnMtnkWN7zMqvHMRb4AG9d7oaEh0pdufCRROk/Ohb5+fXLzaRQAIPOvj5U3G+ZxkeN 9XceI8by/62SXd2aOcNGXtJoju9Q+P34paFJPsfLka8k6wLczhEx1HEQWs9uO0l5w1Fv 17gXoNw44BoFxH6lstHEaU1AuHj0FI/jFivnLi9iCg/vxJKdEiCwV5RF1sZZEFLG+EhC BXzq94w+qF1kcgmbK4koARSzYEXEJuc0Cn7r/71bf89SSLGJjXL+Fe7YIQuJO/z8TUmh twkw== X-Gm-Message-State: AOAM531fLmNsn9/VT5Q1fCH1q742GU7lXfbj5fYnFVm73/z4dmgmYtip t2hBmE2cmo8f3ESHbjO5cc8IhW2d X-Google-Smtp-Source: ABdhPJwbA5DIpZgKjkbW5v4VN0dDPLh8ElqMeZzUOatVchhLG9bG4zbM0npXKWlBud0eQGmNYyEONA== X-Received: by 2002:ac8:36c8:: with SMTP id b8mr18131242qtc.212.1589853349593; Mon, 18 May 2020 18:55:49 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 01/19] Document ioemu MiniOS stubdomain protocol Date: Mon, 18 May 2020 21:54:45 -0400 Message-Id: <20200519015503.115236-2-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Jason Andryuk , Andrew Cooper , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , George Dunlap , Jan Beulich , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Add documentation based on reverse-engineered toolstack-ioemu stubdomain protocol. Signed-off-by: Marek Marczykowski-G=C3=B3recki Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v6: - Add Acked-by: Ian Jackson --- docs/misc/stubdom.txt | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/docs/misc/stubdom.txt b/docs/misc/stubdom.txt index 882a18cab4..64c77d9b64 100644 --- a/docs/misc/stubdom.txt +++ b/docs/misc/stubdom.txt @@ -23,6 +23,59 @@ and https://wiki.xen.org/wiki/Device_Model_Stub_Domains = for more information on device model stub domains =20 =20 +Toolstack to MiniOS ioemu stubdomain protocol +--------------------------------------------- + +This section describe communication protocol between toolstack and +qemu-traditional running in MiniOS stubdomain. The protocol include +expectations of both qemu and stubdomain itself. + +Setup (done by toolstack, expected by stubdomain): + - Block devices for target domain are connected as PV disks to stubdomain, + according to configuration order, starting with xvda + - Network devices for target domain are connected as PV nics to stubdomai= n, + according to configuration order, starting with 0 + - if graphics output is expected, VFB and VKB devices are set for stubdom= ain + (its backend is responsible for exposing them using appropriate protocol + like VNC or Spice) + - other target domain's devices are not connected at this point to stubdo= main + (may be hot-plugged later) + - QEMU command line (space separated arguments) is stored in + /vm//image/dmargs xenstore path + - target domain id is stored in /local/domain//target xenstor= e path +?? - bios type is stored in /local/domain//hvmloader/bios + - stubdomain's console 0 is connected to qemu log file + - stubdomain's console 1 is connected to qemu save file (for saving state) + - stubdomain's console 2 is connected to qemu save file (for restoring st= ate) + - next consoles are connected according to target guest's serial console = configuration + +Startup: +1. PV stubdomain is started with ioemu-stubdom.gz kernel and no initrd +2. stubdomain initialize relevant devices +3. stubdomain signal readiness by writing "running" to /local/domain//device-model//state xenstore path +4. now stubdomain is considered running + +Runtime control (hotplug etc): +Toolstack can issue command through xenstore. The sequence is (from toolst= ack POV): +1. Write parameter to /local/domain//device-model//= parameter. +2. Write command to /local/domain//device-model//co= mmand. +3. Wait for command result in /local/domain//device-model//state (command specific value). +4. Write "running" back to /local/domain//device-model//state. + +Defined commands: + - "pci-ins" - PCI hot plug, results: + - "pci-inserted" - success + - "pci-insert-failed" - failure + - "pci-rem" - PCI hot remove, results: + - "pci-removed" - success + - ?? + - "save" - save domain state to console 1, results: + - "paused" - success + - "continue" - resume domain execution, after loading state from console = 2 (require -loadvm command argument), results: + - "running" - success + + + PV-GRUB =3D=3D=3D=3D=3D=3D=3D =20 --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853389; cv=none; d=zohomail.com; s=zohoarc; b=Nx37DwMASKf4ZJrq5zfdcsiN98PtI6uVOpTfsjJZZvgp0HdlD0zW/I4fPMXflRWnUw0Mg3BN3ABY5Aw9aKxzieyYchAwY9EvL+688RWPD5dKVP/xso9pmcR6R1QG9tuia9HPaRPj9gibl75XQX9JpdU7ZOfHrGseaA79CyeRiac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RY6wcLegoM0K/cf+d7rR6BE972Bl6q9Nr9kajAEhtQU=; b=ar1bOiH6I9DbXUV64qA1SLAL0xI1jxkIEve5EuZuR377vxu+FWewDdDcjDhem+aCJdGtS147UfAj93ZaaKVc6M2E2ch6weSeI13zG/TO8WtJWkAK0EH3XgsoZVOpOgxPMvAkAy+Y2ZxsR8NCO3o1jgDOKMpswXIITasKOqu9loY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853389362196.0475797931665; Mon, 18 May 2020 18:56:29 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarU7-00009H-8o; Tue, 19 May 2020 01:55:59 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarU5-00009A-LC for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:55:57 +0000 Received: from mail-qt1-x842.google.com (unknown [2607:f8b0:4864:20::842]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id deb56f9e-9973-11ea-ae69-bc764e2007e4; Tue, 19 May 2020 01:55:52 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id x12so9905710qts.9 for ; Mon, 18 May 2020 18:55:52 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:55:51 -0700 (PDT) X-Inumbo-ID: deb56f9e-9973-11ea-ae69-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RY6wcLegoM0K/cf+d7rR6BE972Bl6q9Nr9kajAEhtQU=; b=SsM8Xfz9X8ftXAmMO3K2D+HZByZc98cziQKaRFGUs1Gu/T9Yph4QEuD9FtYMPzP6IW CVpPOBI3oVZpocFP4HSHXUjDV+lJQNVOVneFVYzhpEE0gGdm6ihTFxmLOoe7ObFKvwVU 2ovyorxvRYxOICjJOgIm+11kP77OwYHLvOt9JIrWs08Er1/yQgBYXvzttP+bCv41R+UB 5p7RibXTXL24ezP1VRbODzk7dKy0g9HjkbFuvNh1iG7/2SAOFOlOjOWIxsp1LZRDWkz3 mLXAUzAWAn+HYbPe3muVnK+/MR7Xp+yhG106aU5cCkumMRVGlGOnXXpcmwyRhSDqDgkT 34dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RY6wcLegoM0K/cf+d7rR6BE972Bl6q9Nr9kajAEhtQU=; b=HhbKefTGFbselbj6QdKWhO9YrWpEdTpv0puqErlV39ABv+Dh26fWI4Srm7jrv70wz3 AD6oQ9fHmoGGNHIsN701v7sZm0sXTRF0xsHBSSARAvgWVGBNUjai5/VkCa1DJIAQe0f2 VuZKA9XJ54UB9LzJsdSwpuV85qrCmEKgMKGF8EKY98BBCo2lpyRIZiIIt0tO/NeWEDa5 cWCmShimiz234IOPUqBMWXnj765IgV+jemdKDwwyoSIam2qjjXmgJmlXwrOYkJ63PmWh didNQ44w/MLXlZK1vyfBSTGVmi+Hlehytkk4a5xLXNHhRQKbJrGrfQ/6yaTprDIcDQ8u 83Tg== X-Gm-Message-State: AOAM533sV5JUX+mHwPUGUp4Wcw3XHgvWX0wsoFfqBCJeFCh5ka9DvHUh m70Jf/3koun7BqcTO5sHXqDxHeRX X-Google-Smtp-Source: ABdhPJz9SwvFInDwhZCq7+sLwCbi3noQSsm8AYUsROaamQ7COBgQpKKaYKmnKgTpCzzQWAnO08ED/w== X-Received: by 2002:ac8:554c:: with SMTP id o12mr18747723qtr.89.1589853351842; Mon, 18 May 2020 18:55:51 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 02/19] Document ioemu Linux stubdomain protocol Date: Mon, 18 May 2020 21:54:46 -0400 Message-Id: <20200519015503.115236-3-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Jason Andryuk , Andrew Cooper , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , George Dunlap , Jan Beulich , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Add documentation for upcoming Linux stubdomain for qemu-upstream. Signed-off-by: Marek Marczykowski-G=C3=B3recki Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v6: - Add Acked-by: Ian Jackson - Replace dmargs with dm-argv for xenstore directory - Explain $STUBDOM_RESTORE_INCOMING_ARG for -incoming restore argument --- docs/misc/stubdom.txt | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/docs/misc/stubdom.txt b/docs/misc/stubdom.txt index 64c77d9b64..c717a95d17 100644 --- a/docs/misc/stubdom.txt +++ b/docs/misc/stubdom.txt @@ -75,6 +75,58 @@ Defined commands: - "running" - success =20 =20 +Toolstack to Linux ioemu stubdomain protocol +-------------------------------------------- + +This section describe communication protocol between toolstack and +qemu-upstream running in Linux stubdomain. The protocol include +expectations of both stubdomain, and qemu. + +Setup (done by toolstack, expected by stubdomain): + - Block devices for target domain are connected as PV disks to stubdomain, + according to configuration order, starting with xvda + - Network devices for target domain are connected as PV nics to stubdomai= n, + according to configuration order, starting with 0 + - [not implemented] if graphics output is expected, VFB and VKB devices a= re set for stubdomain + (its backend is responsible for exposing them using appropriate protocol + like VNC or Spice) + - other target domain's devices are not connected at this point to stubdo= main + (may be hot-plugged later) + - QEMU command line is stored in + /vm//image/dm-argv xenstore dir, each argument as separate= key + in form /vm//image/dm-argv/NNN, where NNN is 0-padded argu= ment + number + - target domain id is stored in /local/domain//target xenstor= e path +?? - bios type is stored in /local/domain//hvmloader/bios + - stubdomain's console 0 is connected to qemu log file + - stubdomain's console 1 is connected to qemu save file (for saving state) + - stubdomain's console 2 is connected to qemu save file (for restoring st= ate) + - next consoles are connected according to target guest's serial console = configuration + +Environment exposed by stubdomain to qemu (needed to construct appropriate= qemu command line and later interact with qmp): + - target domain's disks are available as /dev/xvd[a-z] + - console 2 (incoming domain state) must be connected to an FD and the co= mmand + line argument $STUBDOM_RESTORE_INCOMING_ARG must be replaced with fd:$F= D to + form "-incoming fd:$FD" + - console 1 (saving domain state) is added over QMP to qemu as "fdset-id = 1" (done by stubdomain, toolstack doesn't need to care about it) + - nics are connected to relevant stubdomain PV vifs when available (qemu = -netdev should specify ifname=3D explicitly) + +Startup: +1. toolstack starts PV stubdomain with stubdom-linux-kernel kernel and stu= bdom-linux-initrd initrd +2. stubdomain initialize relevant devices +3. stubdomain starts qemu with requested command line, plus few stubdomain= specific ones - including local qmp access options +4. stubdomain starts vchan server on /local/domain//device-mod= el//qmp-vchan, exposing qmp socket to the toolstack +5. qemu signal readiness by writing "running" to /local/domain//device-model//state xenstore path +6. now device model is considered running + +QEMU can be controlled using QMP over vchan at /local/domain//= device-model//qmp-vchan. Only one simultaneous connection is sup= ported and toolstack needs to ensure that. + +Limitations: + - PCI passthrough require permissive mode + - only one nic is supported + - at most 26 emulated disks are supported (more are still available as PV= disks) + - graphics output (VNC/SDL/Spice) not supported + =20 PV-GRUB =3D=3D=3D=3D=3D=3D=3D --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853389; cv=none; d=zohomail.com; s=zohoarc; b=R20eDdWWp8MGChpfJj74IMho2lFAOMHAmxV02dQqahG9TmK2Oq1gM25RLuzCt/MsHdYN3mRYl+8cRn5BXjkL86E5RM+mQy+lPOLpvYpRCEQSQeHp5J+/u6z3F+3hzsgkIPbunB4MhkGjJyOALL2DOA9odHPLYpvGWj4CY/vVonA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3tvoe8SF1AjGsABKutuEKPrEzuPGqgtVPQhRYGoZ/qw=; b=LxdJ9x8KTKd1h2HfqW6hHGWdxmfgXkzFdTIvho8coNTCyOMhtq6HATth9D1BnNw4X701a3DR/bMayj5UVEnh6sDQeQRHclKctRUaFBoZGAe/0DWquqwWfKMPBCBTbd40wDfd47wD++YweGGD+Bn9quUEb8IK2L8aSh83ECrLq50= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853389155794.6091705210576; Mon, 18 May 2020 18:56:29 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUC-0000AL-H9; Tue, 19 May 2020 01:56:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUA-0000A7-Lo for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:02 +0000 Received: from mail-qk1-x743.google.com (unknown [2607:f8b0:4864:20::743]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dfcb737e-9973-11ea-b07b-bc764e2007e4; Tue, 19 May 2020 01:55:54 +0000 (UTC) Received: by mail-qk1-x743.google.com with SMTP id n14so12854525qke.8 for ; Mon, 18 May 2020 18:55:54 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:55:53 -0700 (PDT) X-Inumbo-ID: dfcb737e-9973-11ea-b07b-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3tvoe8SF1AjGsABKutuEKPrEzuPGqgtVPQhRYGoZ/qw=; b=mtmHxT/nE6SREvNjSTa70xknAuOQYCx3mhJxYqKW85A3On172I5aHclVH4KtBHHOoT wOnMHUayFj8Z4zzIVlul9ezbk7gVx1yjmoE5CGuHqgw88MMd1JxZDtMb45Zu97BX/Yo9 LF1NF7C2VLdrRkFAhqNfujQ+aL/Ynn7HMS4FRNmnvzlxvlBWBX++kmklq6lZ9Ll5EVvI bAuqUU8QCnaBqJqH5U0ZynbreaZF+NOG4Z4hg1RNhCBTxau6UubxlS7t7vmv7EIKPXln /qOyDtZZ3vt9eCQBnhsrqcDM1bXgGmedKH7dPeplz2jXSevSfL8gwLjGo/ykyUReeYjY nW2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3tvoe8SF1AjGsABKutuEKPrEzuPGqgtVPQhRYGoZ/qw=; b=MbYjBBQlcM6H6vdxpRtth6Aa/+5uy8FxaJCgNiACT2Du6pnuL+HGB7JpDBh5NyWFl/ RqpYC6pVX9mLTFCqLkfAz+cuXduku+QyycA4PCg4ujI7YYT9vFCj69wN2E6q5g3UsC2H y2GklUngD0eh0d1sVoqsHnu2PPy9wHidr+OAT+ezVK6RiR328cC8+wxlSXTnDZJjKwrd DG7lOdMQsD+yK/trGDIblhYOuyttUaYUYnHc/QhhQ/lPJ1hPED3W4jm7Dm9Li9wLbrne ANrE8Bff8DDBSPhRVQpHkGYKGQIv5bCoZEbKkqB9muBd5O4aEq8cM1FPrPwbpfD3gevv YHLw== X-Gm-Message-State: AOAM530HiauYalJPlcROLdqw7tnE8/nU1farCmo8TZPO1LaXx7AnLJNq mGC1pVTpf8XKOMUqIiYzVq9Hdf26 X-Google-Smtp-Source: ABdhPJyYIiU6vwj09ZG7ffxrFoNLNx6KlximjmsF7KaLQBQ/lZA6U6mHSo6feSFCergEFepY74bWYg== X-Received: by 2002:a37:5146:: with SMTP id f67mr4070554qkb.308.1589853353718; Mon, 18 May 2020 18:55:53 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 03/19] libxl: fix qemu-trad cmdline for no sdl/vnc case Date: Mon, 18 May 2020 21:54:47 -0400 Message-Id: <20200519015503.115236-4-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Jason Andryuk , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Anthony PERARD , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki When qemu is running in stubdomain, any attempt to initialize vnc/sdl there will crash it (on failed attempt to load a keymap from a file). If vfb is present, all those cases are skipped. But since b053f0c4c9e533f3d97837cf897eb920b8355ed3 "libxl: do not start dom0 qemu for stubdomain when not needed" it is possible to create a stubdomain without vfb and contrary to the comment -vnc none do trigger VNC initialization code (just skips exposing it externally). Change the implicit SDL avoiding method to -nographics option, used when none of SDL or VNC is enabled. Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Jason Andryuk Acked-by: Ian Jackson Acked-by: Wei Liu Signed-off-by: Jason Andryuk --- Changes in v2: - typo in qemu option Changes in v3: - add missing { } --- tools/libxl/libxl_dm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index f4007bbe50..b91e63db6f 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -734,14 +734,15 @@ static int libxl__build_device_model_args_old(libxl__= gc *gc, if (libxl_defbool_val(vnc->findunused)) { flexarray_append(dm_args, "-vncunused"); } - } else + } else if (!sdl) { /* * VNC is not enabled by default by qemu-xen-traditional, - * however passing -vnc none causes SDL to not be - * (unexpectedly) enabled by default. This is overridden by - * explicitly passing -sdl below as required. + * however skipping -vnc causes SDL to be + * (unexpectedly) enabled by default. If undesired, disable graphi= cs at + * all. */ - flexarray_append_pair(dm_args, "-vnc", "none"); + flexarray_append(dm_args, "-nographic"); + } =20 if (sdl) { flexarray_append(dm_args, "-sdl"); --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853390; cv=none; d=zohomail.com; s=zohoarc; b=L2MPBUs2Q6o4mdXf+4KVj9v6siaTmS20at3rmkr1wBBPnjRMmgiq6YBjmk9/PU39QqdFG/QuEmis2ughoJcsEdVow/0I6I+IUfc+W3SJHrbH8lGKVQWu2l1hkOMScA0KA/YPyV1whZQZtBLpgn7BNY/Dopu3Gu/I/a/P1rBlYRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853390; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BWSyY9N8FyMXoF1yPMPDtUrpbXjsGUwF5REIL/gyKE4=; b=WfqMzRXZZdMWhiznC20Hrt9TIksno0ZUwGoaa0wGcFfrzSoMz1M5IPt9m26mIr2AXxld6AVdxz3zPSLNw3aAeqAY0R7jNwlD0Qb9b0JffOffcxeXMysuMbdUa3cADIiVSKXb97obxotfJ4ANOMMidwOFju7QytNoTUXHpGMxXfU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853390828449.8435620407116; Mon, 18 May 2020 18:56:30 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUF-0000BZ-UM; Tue, 19 May 2020 01:56:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUF-0000BR-Le for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:07 +0000 Received: from mail-qt1-x841.google.com (unknown [2607:f8b0:4864:20::841]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e0e34fc0-9973-11ea-b9cf-bc764e2007e4; Tue, 19 May 2020 01:55:56 +0000 (UTC) Received: by mail-qt1-x841.google.com with SMTP id a23so4202362qto.1 for ; Mon, 18 May 2020 18:55:56 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:55:54 -0700 (PDT) X-Inumbo-ID: e0e34fc0-9973-11ea-b9cf-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BWSyY9N8FyMXoF1yPMPDtUrpbXjsGUwF5REIL/gyKE4=; b=Q0G9EomtPMD43HAyYImzQGewd2pJhclm7ewCrDYgUizNdkAWPHdd/QDAqRrtwxE1Ud 5C75344oe2RDuNnL/Rz8h3RzCAR3I7u3RGuVSrI8wgHSfnDiccr9Ygjig8Ckk/uMT2bM mayjHbihTwnBIeuVgu0XGn+9PakxiyYJRKKlA4oMrQ8Eyfe6RNyfHgP74dha0tlwkR9W N/21firtYqCM0w/UvCi+MLl5T55+shmdMlnc/qx21hQkOAE0ku1UjhHKgfYaENQ0UaY3 8pwu0hIwdnQx9JTzNVxgi6zy63DrbIkL1IeW2MuPCzqeHmX2AJooCWIlMego33/mktcd aZlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BWSyY9N8FyMXoF1yPMPDtUrpbXjsGUwF5REIL/gyKE4=; b=QpjqAIL8BXrDKVm3boz7DF/oLZS/VCLQN1AbntS7IK7TFBePZFYPdSEFo3JZO0mJkh cj+F/IAAiCNbXxl5Un1p9VXiH86l45vmqILR+P4Pz+wAGn6hqTBU8fdip5kZFyywDNKU uodiVLfunFiikC1fgpkNKAqO97D824a4j7V9fzIBBLhQYWpKVsuTH1u57VKKFOAXIU+u snTHTqnpwQkZQWlLvAfxo/5k3nHlIHeoMUyS3kvlCXH8KtBUE3/zlNqYzhNTs9m+A3AG bdJ0sMj0MgAk9K9lOCcMfK1MtUCTh/51y+ieom/ygSWxR45nmeCh+43jVuaz626SP3dT b08A== X-Gm-Message-State: AOAM531aMxG3KIDjjpeScgUIHv+41h+DFh/F3uemrSi2Nk8DabxHK8aI 36kpkqRBDZPML73t7xdVhiaH+3JR X-Google-Smtp-Source: ABdhPJzIp16aUQq7pmPkVxIO1Nsj4UJOrCx67rkQXO1uauxrQu18+nrF0NgGcZXQSrV72ttKJ2sGHg== X-Received: by 2002:aed:2b67:: with SMTP id p94mr19592117qtd.255.1589853355425; Mon, 18 May 2020 18:55:55 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 04/19] libxl: Allow running qemu-xen in stubdomain Date: Mon, 18 May 2020 21:54:48 -0400 Message-Id: <20200519015503.115236-5-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Jason Andryuk , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Anthony PERARD , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Do not prohibit anymore using stubdomain with qemu-xen. To help distingushing MiniOS and Linux stubdomain, add helper inline functions libxl__stubdomain_is_linux() and libxl__stubdomain_is_linux_running(). Those should be used where really the difference is about MiniOS/Linux, not qemu-xen/qemu-xen-traditional. Signed-off-by: Marek Marczykowski-G=C3=B3recki Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v3: - new patch, instead of "libxl: Add "stubdomain_version" to domain_build_info" - helper functions as suggested by Ian Jackson Changes in v6: - Add Acked-by: Ian Jackson --- tools/libxl/libxl_create.c | 9 --------- tools/libxl/libxl_internal.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 5a043df15f..433947abab 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -171,15 +171,6 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, } } =20 - if (b_info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM && - b_info->device_model_version !=3D - LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL && - libxl_defbool_val(b_info->device_model_stubdomain)) { - LOG(ERROR, - "device model stubdomains require \"qemu-xen-traditional\""); - return ERROR_INVAL; - } - if (!b_info->max_vcpus) b_info->max_vcpus =3D 1; if (!b_info->avail_vcpus.size) { diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index e5effd2ad1..d1ebdec8d2 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2324,6 +2324,23 @@ _hidden int libxl__device_model_version_running(libx= l__gc *gc, uint32_t domid); /* Return the system-wide default device model */ _hidden libxl_device_model_version libxl__default_device_model(libxl__gc *= gc); =20 +static inline +bool libxl__stubdomain_is_linux_running(libxl__gc *gc, uint32_t domid) +{ + /* same logic as in libxl__stubdomain_is_linux */ + return libxl__device_model_version_running(gc, domid) + =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN; +} + +static inline +bool libxl__stubdomain_is_linux(libxl_domain_build_info *b_info) +{ + /* right now qemu-tranditional implies MiniOS stubdomain and qemu-xen + * implies Linux stubdomain */ + return libxl_defbool_val(b_info->device_model_stubdomain) && + b_info->device_model_version =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEM= U_XEN; +} + #define DEVICE_MODEL_XS_PATH(gc, dm_domid, domid, fmt, _a...) = \ libxl__sprintf(gc, "/local/domain/%u/device-model/%u" fmt, dm_domid, = \ domid, ##_a) --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853401; cv=none; d=zohomail.com; s=zohoarc; b=h5soKwl1YWHbGgQxV4lQ9D9fZVc+Fo1p3fBSA+VD3ktNuXg2gakz/GS+znWALMWnWcRQqwwQZDNYqStEsHVVVGjpWEDCZypg6nyg4Bul+/zO5u2rERpCKqO4Y2B8/Xfs5iwNmdDuRe/13tKEmlVsztAZMzfPLlIyUMk28a46Lic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853401; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vewEl/AeTk1WX8L90ml6cglMpSrPMmirDuDTRVf5RxA=; b=FcqGUtCD59x8N33YuJslfWuK1FHJoQs6wMPLZ6B1Qp8fz+kstYCHzYuZ12SbynscgHwGhiKWz6adjfhZpNff15/fFclMVq0QIBwTdvNbPUIO9+zyw0xeiaY3vuk3DTLGJ6zLVr32009Mo5S6x1iGC9mhsnVdcKMhjZG2J7Uc9UE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853401350768.0626413271652; Mon, 18 May 2020 18:56:41 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUL-0000Dl-7T; Tue, 19 May 2020 01:56:13 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUK-0000DQ-M7 for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:12 +0000 Received: from mail-qk1-x741.google.com (unknown [2607:f8b0:4864:20::741]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e253143a-9973-11ea-ae69-bc764e2007e4; Tue, 19 May 2020 01:55:58 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id f13so12916804qkh.2 for ; Mon, 18 May 2020 18:55:58 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:55:56 -0700 (PDT) X-Inumbo-ID: e253143a-9973-11ea-ae69-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vewEl/AeTk1WX8L90ml6cglMpSrPMmirDuDTRVf5RxA=; b=rv2n920WU6liSgItKpw3Vw3M/4Bk/r0seoZPRI76yV/tUaUbGm84WQ+QPvwSwdwqZB ujgECBop2AYnbyiyYUwTkinpOPeYTE6ZuMdkryGsju8Ol0wNGUAI9ldlZFftkE4EOuBY VZj7uJjdT5XRBeWydO/LAgexJj/NsPw7WofcB9p1p1Xxyz2iEYvpakGn7jpkTgwXGdvc 1OGamQFERfc3OHVIdoUcx8uRFVpI3tAwnCeYSOovIogkzFeniBpZ2YeC54nhZHojRAvs okC8WhT24+xvqaX5XCyovt0Cagmt56/KmG7eDVfJubEI0sVNbUEfiVgKMPvOs7BXhhTt jgTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vewEl/AeTk1WX8L90ml6cglMpSrPMmirDuDTRVf5RxA=; b=F4VBWUvLniKs1GGpad2Pvpw7ipKWJK7f+wpOhcxNX/lOe82Q3OEkjl/I21oTylUGB8 U6eqSUY8a4IHfsX1vn714UgZ5dBNo2+VAWhsSD1mDNEVTEytea9BkKIPB7girPbtPPN8 tca5OkQOvuZkHl+Yj0XLsvoj00HoQujzYJgWNz0DRYUaURsWB40Xboxki523lFgRkW/Z W1CrSO3vXo1jrnDEAmrhTn+fGULOqNhvFDAgMQtNkjaPdlH5RNBJY1rFGgM51x8Qb1KO 34lOAxIZtbmD+QuCdozp+dz/ohtwM8CZHgKMEHUbO/BvBNPDqRe5+JAYsytZfFXCWz28 3hqQ== X-Gm-Message-State: AOAM531uyK0mgodxUjxUs5blv4NLHtAtOfAjoCAFDCu/1jaXhFK0ZDFW hTrjvnkK3W7S9Uepj9MpUFM3u6aD X-Google-Smtp-Source: ABdhPJzUF4VUF27OWobT5fWJy3ECSiDxUcWxrjg8qtMaFpOPURt85LGpUDFgsFEhCxKIY8xYNvH+kQ== X-Received: by 2002:a37:2f86:: with SMTP id v128mr8873101qkh.413.1589853357504; Mon, 18 May 2020 18:55:57 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 05/19] libxl: Handle Linux stubdomain specific QEMU options. Date: Mon, 18 May 2020 21:54:49 -0400 Message-Id: <20200519015503.115236-6-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Jason Andryuk , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Simon Gaiser , Anthony PERARD , Ian Jackson , Eric Shelton Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Eric Shelton This patch creates an appropriate command line for the QEMU instance running in a Linux-based stubdomain. NOTE: a number of items are not currently implemented for Linux-based stubdomains, such as: - save/restore - QMP socket - graphics output (e.g., VNC) Signed-off-by: Eric Shelton Simon: * fix disk path * fix cdrom path and "format" Signed-off-by: Simon Gaiser [drop Qubes-specific parts] Signed-off-by: Marek Marczykowski-G=C3=B3recki Allow setting stubdomain_ramdisk independently from stubdomain_kernel Add a qemu- prefix for qemu-stubdom-linux-{kernel,rootfs} since stubdom doesn't convey device-model. Use qemu- since this code is qemu specific. Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v2: - fix serial specified with serial=3D[ ... ] syntax - error out on multiple consoles (incompatible with stubdom) - drop erroneous chunk about cdrom Changes in v3: - change to use libxl__stubdomain_is_linux instead of b_info->stubdomain_version - drop libxl__stubdomain_version_running, prefer libxl__stubdomain_is_linux_running introduced by previous patch - drop ifup/ifdown script - stubdomain will handle that with qemu events itself - slightly simplify -serial argument - add support for multiple serial consoles, do not ignore b_info.u.serial(_list) - add error checking for more than 26 emulated disks ("/dev/xvd%c" format string) Changes in v5: - commit message fixup to match patch contents - Marek - file names are now qemu-stubdom-linux-{kernel,rootfs} - Jason - allow setting ramdisk independently of kernel - Jason Changes in v6: - Add Acked-by: Ian Jackson - Fixes for style nits --- tools/libxl/libxl_create.c | 45 ++++++++ tools/libxl/libxl_dm.c | 193 ++++++++++++++++++++++++----------- tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_mem.c | 6 +- tools/libxl/libxl_types.idl | 3 + 5 files changed, 186 insertions(+), 62 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 433947abab..8614a2c241 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -171,6 +171,40 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, } } =20 + if (b_info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM && + libxl_defbool_val(b_info->device_model_stubdomain)) { + if (!b_info->stubdomain_kernel) { + switch (b_info->device_model_version) { + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: + b_info->stubdomain_kernel =3D + libxl__abs_path(NOGC, "ioemu-stubdom.gz", libxl__x= enfirmwaredir_path()); + break; + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: + b_info->stubdomain_kernel =3D + libxl__abs_path(NOGC, + "qemu-stubdom-linux-kernel", + libxl__xenfirmwaredir_path()); + break; + default: + abort(); + } + } + if (!b_info->stubdomain_ramdisk) { + switch (b_info->device_model_version) { + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: + break; + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: + b_info->stubdomain_ramdisk =3D + libxl__abs_path(NOGC, + "qemu-stubdom-linux-rootfs", + libxl__xenfirmwaredir_path()); + break; + default: + abort(); + } + } + } + if (!b_info->max_vcpus) b_info->max_vcpus =3D 1; if (!b_info->avail_vcpus.size) { @@ -206,6 +240,17 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, if (b_info->target_memkb =3D=3D LIBXL_MEMKB_DEFAULT) b_info->target_memkb =3D b_info->max_memkb; =20 + if (b_info->stubdomain_memkb =3D=3D LIBXL_MEMKB_DEFAULT) { + if (libxl_defbool_val(b_info->device_model_stubdomain)) { + if (libxl__stubdomain_is_linux(b_info)) + b_info->stubdomain_memkb =3D LIBXL_LINUX_STUBDOM_MEM * 102= 4; + else + b_info->stubdomain_memkb =3D 28 * 1024; // MiniOS + } else { + b_info->stubdomain_memkb =3D 0; // no stubdomain + } + } + libxl_defbool_setdefault(&b_info->claim_mode, false); =20 libxl_defbool_setdefault(&b_info->localtime, false); diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index b91e63db6f..dc1717bc12 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1188,6 +1188,7 @@ static int libxl__build_device_model_args_new(libxl__= gc *gc, int i, connection, devid; uint64_t ram_size; const char *path, *chardev; + bool is_stubdom =3D libxl_defbool_val(b_info->device_model_stubdomain); =20 dm_args =3D flexarray_make(gc, 16, 1); dm_envs =3D flexarray_make(gc, 16, 1); @@ -1197,39 +1198,42 @@ static int libxl__build_device_model_args_new(libxl= __gc *gc, flexarray_vappend(dm_args, dm, "-xen-domid", GCSPRINTF("%d", guest_domid), NULL); + flexarray_append(dm_args, "-no-shutdown"); =20 - flexarray_append(dm_args, "-chardev"); - if (state->dm_monitor_fd >=3D 0) { - flexarray_append(dm_args, - GCSPRINTF("socket,id=3Dlibxl-cmd,fd=3D%d,server,nowait", - state->dm_monitor_fd)); + /* There is currently no way to access the QMP socket in the stubdom */ + if (!is_stubdom) { + flexarray_append(dm_args, "-chardev"); + if (state->dm_monitor_fd >=3D 0) { + flexarray_append(dm_args, + GCSPRINTF("socket,id=3Dlibxl-cmd,fd=3D%d,server,nowait", + state->dm_monitor_fd)); =20 - /* - * Start QEMU with its "CPU" paused, it will not start any emulati= on - * until the QMP command "cont" is used. This also prevent QEMU fr= om - * writing "running" to the "state" xenstore node so we only use t= his - * flag when we have the QMP based startup notification. - * */ - flexarray_append(dm_args, "-S"); - } else { - flexarray_append(dm_args, - GCSPRINTF("socket,id=3Dlibxl-cmd," - "path=3D%s,server,nowait", - libxl__qemu_qmp_path(gc, guest_domid))); - } + /* + * Start QEMU with its "CPU" paused, it will not start any emu= lation + * until the QMP command "cont" is used. This also prevent QEM= U from + * writing "running" to the "state" xenstore node so we only u= se this + * flag when we have the QMP based startup notification. + * */ + flexarray_append(dm_args, "-S"); + } else { + flexarray_append(dm_args, + GCSPRINTF("socket,id=3Dlibxl-cmd," + "path=3D%s,server,nowait", + libxl__qemu_qmp_path(gc, guest_domi= d))); + } =20 - flexarray_append(dm_args, "-no-shutdown"); - flexarray_append(dm_args, "-mon"); - flexarray_append(dm_args, "chardev=3Dlibxl-cmd,mode=3Dcontrol"); + flexarray_append(dm_args, "-mon"); + flexarray_append(dm_args, "chardev=3Dlibxl-cmd,mode=3Dcontrol"); =20 - flexarray_append(dm_args, "-chardev"); - flexarray_append(dm_args, - GCSPRINTF("socket,id=3Dlibxenstat-cmd," - "path=3D%s/qmp-libxenstat-%d,server,no= wait", - libxl__run_dir_path(), guest_domid)); + flexarray_append(dm_args, "-chardev"); + flexarray_append(dm_args, + GCSPRINTF("socket,id=3Dlibxenstat-cmd," + "path=3D%s/qmp-libxenstat-%d,serve= r,nowait", + libxl__run_dir_path(), guest_domid= )); =20 - flexarray_append(dm_args, "-mon"); - flexarray_append(dm_args, "chardev=3Dlibxenstat-cmd,mode=3Dcontrol"); + flexarray_append(dm_args, "-mon"); + flexarray_append(dm_args, "chardev=3Dlibxenstat-cmd,mode=3Dcontrol= "); + } =20 for (i =3D 0; i < guest_config->num_channels; i++) { connection =3D guest_config->channels[i].connection; @@ -1273,7 +1277,7 @@ static int libxl__build_device_model_args_new(libxl__= gc *gc, flexarray_vappend(dm_args, "-name", c_info->name, NULL); } =20 - if (vnc) { + if (vnc && !is_stubdom) { char *vncarg =3D NULL; =20 flexarray_append(dm_args, "-vnc"); @@ -1312,11 +1316,12 @@ static int libxl__build_device_model_args_new(libxl= __gc *gc, } =20 flexarray_append(dm_args, vncarg); - } else + } else if (!is_stubdom) { /* * Ensure that by default no vnc server is created. */ flexarray_append_pair(dm_args, "-vnc", "none"); + } =20 /* * Ensure that by default no display backend is created. Further @@ -1324,7 +1329,7 @@ static int libxl__build_device_model_args_new(libxl__= gc *gc, */ flexarray_append_pair(dm_args, "-display", "none"); =20 - if (sdl) { + if (sdl && !is_stubdom) { flexarray_append(dm_args, "-sdl"); if (sdl->display) flexarray_append_pair(dm_envs, "DISPLAY", sdl->display); @@ -1366,18 +1371,34 @@ static int libxl__build_device_model_args_new(libxl= __gc *gc, { LOGD(ERROR, guest_domid, "Both serial and serial_list set"= ); return ERROR_INVAL; - } - if (b_info->u.hvm.serial) { - flexarray_vappend(dm_args, - "-serial", b_info->u.hvm.serial, NULL); - } else if (b_info->u.hvm.serial_list) { - char **p; - for (p =3D b_info->u.hvm.serial_list; - *p; - p++) { - flexarray_vappend(dm_args, - "-serial", - *p, NULL); + } else { + if (b_info->u.hvm.serial) { + if (is_stubdom) { + /* see spawn_stub_launch_dm() for connecting STUBD= OM_CONSOLE_SERIAL */ + flexarray_vappend(dm_args, + "-serial", + GCSPRINTF("/dev/hvc%d", STUBDOM_= CONSOLE_SERIAL), + NULL); + } else { + flexarray_vappend(dm_args, + "-serial", b_info->u.hvm.serial,= NULL); + } + } else if (b_info->u.hvm.serial_list) { + char **p; + /* see spawn_stub_launch_dm() for connecting STUBDOM_C= ONSOLE_SERIAL */ + for (p =3D b_info->u.hvm.serial_list, i =3D 0; + *p; + p++, i++) { + if (is_stubdom) + flexarray_vappend(dm_args, + "-serial", + GCSPRINTF("/dev/hvc%d", STUB= DOM_CONSOLE_SERIAL + i), + NULL); + else + flexarray_vappend(dm_args, + "-serial", + *p, NULL); + } } } } @@ -1386,7 +1407,7 @@ static int libxl__build_device_model_args_new(libxl__= gc *gc, flexarray_append(dm_args, "-nographic"); } =20 - if (libxl_defbool_val(b_info->u.hvm.spice.enable)) { + if (libxl_defbool_val(b_info->u.hvm.spice.enable) && !is_stubdom) { const libxl_spice_info *spice =3D &b_info->u.hvm.spice; char *spiceoptions =3D dm_spice_options(gc, spice); if (!spiceoptions) @@ -1813,7 +1834,9 @@ static int libxl__build_device_model_args_new(libxl__= gc *gc, * If qemu isn't doing the interpreting, the parameter is * always raw */ - if (disks[i].backend =3D=3D LIBXL_DISK_BACKEND_QDISK) + if (libxl_defbool_val(b_info->device_model_stubdomain)) + format =3D "host_device"; + else if (disks[i].backend =3D=3D LIBXL_DISK_BACKEND_QDISK) format =3D libxl__qemu_disk_format_string(disks[i].format); else format =3D libxl__qemu_disk_format_string(LIBXL_DISK_FORMA= T_RAW); @@ -1824,6 +1847,16 @@ static int libxl__build_device_model_args_new(libxl_= _gc *gc, disks[i].vdev); continue; } + } else if (libxl_defbool_val(b_info->device_model_stubdomain))= { + if (disk > 'z' - 'a') { + LOGD(WARN, guest_domid, + "Emulation of only first %d disks is supported= with qemu-xen in stubdomain.\n" + "Disk %d will be available via PV drivers but = not as an emulated disk.", + 'z' - 'a', + disk); + continue; + } + target_path =3D GCSPRINTF("/dev/xvd%c", 'a' + disk); } else { if (format =3D=3D NULL) { LOGD(WARN, guest_domid, @@ -1964,7 +1997,7 @@ static int libxl__build_device_model_args(libxl__gc *= gc, char ***args, char ***envs, const libxl__domain_build_state *s= tate, int *dm_state_fd) -/* dm_state_fd may be NULL iff caller knows we are using old stubdom +/* dm_state_fd may be NULL iff caller knows we are using stubdom * and therefore will be passing a filename rather than a fd. */ { switch (guest_config->b_info.device_model_version) { @@ -1974,8 +2007,10 @@ static int libxl__build_device_model_args(libxl__gc = *gc, args, envs, state); case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - assert(dm_state_fd !=3D NULL); - assert(*dm_state_fd < 0); + if (!libxl_defbool_val(guest_config->b_info.device_model_stubdomai= n)) { + assert(dm_state_fd !=3D NULL); + assert(*dm_state_fd < 0); + } return libxl__build_device_model_args_new(gc, dm, guest_domid, guest_confi= g, args, envs, @@ -2080,6 +2115,16 @@ retry_transaction: return 0; } =20 +static int libxl__store_libxl_entry(libxl__gc *gc, uint32_t domid, + const char *name, const char *value) +{ + char *path =3D NULL; + + path =3D libxl__xs_libxl_path(gc, domid); + path =3D libxl__sprintf(gc, "%s/%s", path, name); + return libxl__xs_printf(gc, XBT_NULL, path, "%s", value); +} + static void dmss_init(libxl__dm_spawn_state *dmss) { libxl__ev_qmp_init(&dmss->qmp); @@ -2138,10 +2183,14 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__s= tub_dm_spawn_state *sdss) dmss_init(&sdss->pvqemu); libxl__xswait_init(&sdss->xswait); =20 - if (guest_config->b_info.device_model_version !=3D - LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) { - ret =3D ERROR_INVAL; - goto out; + assert(libxl_defbool_val(guest_config->b_info.device_model_stubdomain)= ); + + if (libxl__stubdomain_is_linux(&guest_config->b_info)) { + if (d_state->saved_state) { + LOG(ERROR, "Save/Restore not supported yet with Linux Stubdom.= "); + ret =3D -1; + goto out; + } } =20 sdss->pvqemu.guest_domid =3D INVALID_DOMID; @@ -2163,8 +2212,8 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stu= b_dm_spawn_state *sdss) =20 dm_config->b_info.shadow_memkb =3D 0; dm_config->b_info.max_vcpus =3D 1; - dm_config->b_info.max_memkb =3D 28 * 1024 + - guest_config->b_info.video_memkb; + dm_config->b_info.max_memkb =3D guest_config->b_info.stubdomain_memkb; + dm_config->b_info.max_memkb +=3D guest_config->b_info.video_memkb; dm_config->b_info.target_memkb =3D dm_config->b_info.max_memkb; =20 dm_config->b_info.max_grant_frames =3D guest_config->b_info.max_grant_= frames; @@ -2203,10 +2252,8 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__st= ub_dm_spawn_state *sdss) dm_config->num_vkbs =3D 1; } =20 - stubdom_state->pv_kernel.path - =3D libxl__abs_path(gc, "ioemu-stubdom.gz", libxl__xenfirmwaredir_= path()); - stubdom_state->pv_cmdline =3D GCSPRINTF(" -d %d", guest_domid); - stubdom_state->pv_ramdisk.path =3D ""; + stubdom_state->pv_kernel.path =3D guest_config->b_info.stubdomain_kern= el; + stubdom_state->pv_ramdisk.path =3D guest_config->b_info.stubdomain_ram= disk; =20 /* fixme: this function can leak the stubdom if it fails */ ret =3D libxl__domain_make(gc, dm_config, stubdom_state, @@ -2226,6 +2273,8 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stu= b_dm_spawn_state *sdss) goto out; } =20 + libxl__store_libxl_entry(gc, guest_domid, "dm-version", + libxl_device_model_version_to_string(dm_config->b_info.device_mode= l_version)); libxl__write_stub_dmargs(gc, dm_domid, guest_domid, args); libxl__xs_printf(gc, XBT_NULL, GCSPRINTF("%s/image/device-model-domid", @@ -2235,6 +2284,15 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__st= ub_dm_spawn_state *sdss) GCSPRINTF("%s/target", libxl__xs_get_dompath(gc, dm_domid)), "%d", guest_domid); + if (guest_config->b_info.device_model_version =3D=3D LIBXL_DEVICE_MODE= L_VERSION_QEMU_XEN) { + /* qemu-xen is used as a dm in the stubdomain, so we set the bios + * accroding to this */ + libxl__xs_printf(gc, XBT_NULL, + libxl__sprintf(gc, "%s/hvmloader/bios", + libxl__xs_get_dompath(gc, guest_dom= id)), + "%s", + libxl_bios_type_to_string(guest_config->b_info.u.h= vm.bios)); + } ret =3D xc_domain_set_target(ctx->xch, dm_domid, guest_domid); if (ret<0) { LOGED(ERROR, guest_domid, "setting target domain %d -> %d", @@ -2314,8 +2372,13 @@ static void spawn_stub_launch_dm(libxl__egc *egc, if (ret) goto out; } =20 - if (guest_config->b_info.u.hvm.serial) + if (guest_config->b_info.u.hvm.serial) { num_console++; + } else if (guest_config->b_info.u.hvm.serial_list) { + char **serial =3D guest_config->b_info.u.hvm.serial_list; + while (*(serial++)) + num_console++; + } =20 console =3D libxl__calloc(gc, num_console, sizeof(libxl__device_consol= e)); =20 @@ -2349,8 +2412,18 @@ static void spawn_stub_launch_dm(libxl__egc *egc, console[i].output =3D GCSPRINTF("pipe:%s", d_state->saved_state); break; + case STUBDOM_CONSOLE_SERIAL: + if (guest_config->b_info.u.hvm.serial) { + console[i].output =3D guest_config->b_info.u.hvm.seria= l; + break; + } + /* fall-through */ default: - console[i].output =3D "pty"; + /* Serial_list is set, as otherwise num_consoles would be + * smaller and consoles 0-2 are handled above. */ + assert(guest_config->b_info.u.hvm.serial_list); + console[i].output =3D guest_config->b_info.u.hvm.serial_li= st[ + i-STUBDOM_CONSOLE_SERIAL]; break; } } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index d1ebdec8d2..f2f76439ec 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -119,6 +119,7 @@ #define STUBDOM_CONSOLE_RESTORE 2 #define STUBDOM_CONSOLE_SERIAL 3 #define STUBDOM_SPECIAL_CONSOLES 3 +#define LIBXL_LINUX_STUBDOM_MEM 128 #define TAP_DEVICE_SUFFIX "-emu" #define DOMID_XS_PATH "domid" #define PVSHIM_BASENAME "xen-shim" diff --git a/tools/libxl/libxl_mem.c b/tools/libxl/libxl_mem.c index bc7b95aa74..e52a9624ea 100644 --- a/tools/libxl/libxl_mem.c +++ b/tools/libxl/libxl_mem.c @@ -459,8 +459,10 @@ int libxl__domain_need_memory_calculate(libxl__gc *gc, case LIBXL_DOMAIN_TYPE_PVH: case LIBXL_DOMAIN_TYPE_HVM: *need_memkb +=3D LIBXL_HVM_EXTRA_MEMORY; - if (libxl_defbool_val(b_info->device_model_stubdomain)) - *need_memkb +=3D 32 * 1024; + if (libxl_defbool_val(b_info->device_model_stubdomain)) { + *need_memkb +=3D b_info->stubdomain_memkb; + *need_memkb +=3D b_info->video_memkb; + } break; case LIBXL_DOMAIN_TYPE_PV: *need_memkb +=3D LIBXL_PV_EXTRA_MEMORY; diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index f7c473be74..9d3f05f399 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -518,6 +518,9 @@ libxl_domain_build_info =3D Struct("domain_build_info",[ =20 ("device_model_version", libxl_device_model_version), ("device_model_stubdomain", libxl_defbool), + ("stubdomain_memkb", MemKB), + ("stubdomain_kernel", string), + ("stubdomain_ramdisk", string), # if you set device_model you must set device_model_version too ("device_model", string), ("device_model_ssidref", uint32), --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853402; cv=none; d=zohomail.com; s=zohoarc; b=fmlwGdfxIrMew+tVEdgb2sSsQxrPmxg5UDyWEXP3YUpoGPKPkd90SEOy1dg2oYNS75Nx5xmGCnbUu89uEOcsTZMRvAXua6IbjIG9e07X0tTftSeVJGPKwfpGOrBq3pguBcZqHSl68fL2MI7m4II3SeqHmgJm8QNm7DMRBalkTGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853402; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EhWGeBO5fU7aDrFb+y6kocNrTThgXEXh85XiUI3Yqtk=; b=E7pGjuj+T3SiuHpBb360LY3xiFD5Rf2GuVLfVRMr+grUjxUI+V1FAZ+sjNs4EzVCq/H9UvOxBSPFfMmf4CYoFn+ZkdHVUB4BGu80m3Puo2lzD79qEy3l05msXCKz0n5MqUSsnalJMMlVG/RJNYbxdubYVaoGFtrpk8LlbURYfNw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853402973901.0124647744733; Mon, 18 May 2020 18:56:42 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUQ-0000Gn-Lb; Tue, 19 May 2020 01:56:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUP-0000GG-MQ for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:17 +0000 Received: from mail-qk1-x742.google.com (unknown [2607:f8b0:4864:20::742]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e3264774-9973-11ea-ae69-bc764e2007e4; Tue, 19 May 2020 01:56:00 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id i14so12816912qka.10 for ; Mon, 18 May 2020 18:55:59 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:55:58 -0700 (PDT) X-Inumbo-ID: e3264774-9973-11ea-ae69-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EhWGeBO5fU7aDrFb+y6kocNrTThgXEXh85XiUI3Yqtk=; b=Q35bbi2GYRG7GMFM+chG/uml8bUSKpczo3cdkK6Ozevr/n36ollyZpZ9ItTpBOvtyO 6lcquzv2Axb0fOjT3wDgSrOarDUl0JJTZqk2XaPobUy6AYMxiuuHBqM1SVQaslg/O7Hv HZsyLP3BvB6WXfxXYPlb+FCDx5FZA6gn4mAgHMn+X4/zQdHsVPbTn8JfhfSd44XWSWuD 1HE1BnBjVu5shGWrPbbFOyPpBs7EBwm1FImruCoomq4wNgCQyehNjmec8dOvZlJM4ur/ 6MbLPPTYkxMvR/lNrXdaWkEAd1MbgLMXBIqHeTxRPgYsZaikdf+c7xgsCfB2qBnl3ulm id0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EhWGeBO5fU7aDrFb+y6kocNrTThgXEXh85XiUI3Yqtk=; b=YaQFlG6HeNF/Kv3JGG4Hx+PnIj7n+8R716PXalSEapQkZCLFRk2ror3ZnOTbkQWIMc BgMwoIPaRK+ugpyo2SmeNgI4tno6ficbEitQRrYVcjMGwQhWtkJblOOE637Be1KerpXH 3hSpMuud2WgbkQKY7cNIrPFCFQ/d/pt/S8QkeyD72JFDZtIf2IJl+SzENScxDLpxoTFz jkcvSS7JtmXONudUDcN1MpnxlntJZinQFSpfAuFnKdwSnAOBPkT5IwuOdQS7IRc4JOX5 pl1biYpizvhF9mveQ+JY4BjW2/b6ONUUr0JjLO3NHC3+mDJcH4VNk6b5sJoibekiuVdj N5GA== X-Gm-Message-State: AOAM531K/YDYKB9Og31qefdgWVPjue3+TOsKdNQ+nFmJw3dQhy0l9QVN 8CiXXK+fXZBpB4HPSQV8c1J584P8 X-Google-Smtp-Source: ABdhPJwUZdL8WFdvXxXr0MTV4ZtRNTzB4gw/6FXjEUyXqs+QDg7lH5C8GZD7oO58aw6rQCbbxFFMjw== X-Received: by 2002:a37:8d07:: with SMTP id p7mr19191071qkd.500.1589853359370; Mon, 18 May 2020 18:55:59 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 06/19] libxl: Use libxl__xs_* in libxl__write_stub_dmargs Date: Mon, 18 May 2020 21:54:50 -0400 Message-Id: <20200519015503.115236-7-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , Wei Liu , Jason Andryuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Re-work libxl__write_stub_dmargs to use libxl_xs_* functions in a loop. Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- New in v7 --- tools/libxl/libxl_dm.c | 53 ++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index dc1717bc12..8e57cd8c1f 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2070,21 +2070,18 @@ static int libxl__write_stub_dmargs(libxl__gc *gc, int dm_domid, int guest_domid, char **args) { - libxl_ctx *ctx =3D libxl__gc_owner(gc); int i; - char *vm_path; - char *dmargs, *path; + char *dmargs; int dmargs_size; struct xs_permissions roperm[2]; - xs_transaction_t t; + xs_transaction_t t =3D XBT_NULL; + int rc; =20 roperm[0].id =3D 0; roperm[0].perms =3D XS_PERM_NONE; roperm[1].id =3D dm_domid; roperm[1].perms =3D XS_PERM_READ; =20 - vm_path =3D libxl__xs_read(gc, XBT_NULL, GCSPRINTF("/local/domain/%d/v= m", guest_domid)); - i =3D 0; dmargs_size =3D 0; while (args[i] !=3D NULL) { @@ -2102,17 +2099,43 @@ static int libxl__write_stub_dmargs(libxl__gc *gc, } i++; } - path =3D GCSPRINTF("%s/image/dmargs", vm_path); =20 -retry_transaction: - t =3D xs_transaction_start(ctx->xsh); - xs_write(ctx->xsh, t, path, dmargs, strlen(dmargs)); - xs_set_permissions(ctx->xsh, t, path, roperm, ARRAY_SIZE(roperm)); - xs_set_permissions(ctx->xsh, t, GCSPRINTF("%s/rtc/timeoffset", vm_path= ), roperm, ARRAY_SIZE(roperm)); - if (!xs_transaction_end(ctx->xsh, t, 0)) - if (errno =3D=3D EAGAIN) - goto retry_transaction; + for (;;) { + const char *vm_path; + char *path; + + rc =3D libxl__xs_transaction_start(gc, &t); + if (rc) goto out; + + rc =3D libxl__xs_read_mandatory(gc, t, + GCSPRINTF("/local/domain/%d/vm", + guest_domid), + &vm_path); + if (rc) goto out; + + path =3D GCSPRINTF("%s/image/dmargs", vm_path); + + rc =3D libxl__xs_mknod(gc, t, path, roperm, ARRAY_SIZE(roperm)); + if (rc) goto out; + + rc =3D libxl__xs_write_checked(gc, t, path, dmargs); + if (rc) goto out; + + rc =3D libxl__xs_mknod(gc, t, GCSPRINTF("%s/rtc/timeoffset", vm_pa= th), + roperm, ARRAY_SIZE(roperm)); + if (rc) goto out; + + rc =3D libxl__xs_transaction_commit(gc, &t); + if (!rc) break; + if (rc<0) goto out; + } + return 0; + + out: + libxl__xs_transaction_abort(gc, &t); + + return rc; } =20 static int libxl__store_libxl_entry(libxl__gc *gc, uint32_t domid, --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853405; cv=none; d=zohomail.com; s=zohoarc; b=MZXpnl+uV5Z8JscXHVwzd7wqmDOIrn4raLLeAL/c6sOwMnQPDwzJHHUcJE9WcEkueYd8m8puIKsxZ7bKjfES9f7cHjRDnxuVFZr+388fl1L6GNP0zMa7k4z1W4lP8KnqFlfZNzlO+sLFW5HrtyAaNt4wgE/EkhCX0Ed41HMD4M8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853405; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e8TO7h61vMYwatja+1Xk6Uhtwz9m20nO7NIF4kE+skE=; b=TYpBedVydBe8gj3ZCBYhC9DQjH2P3+67YiSLf7gaG18xk15FywQhQTJX5IH5oXy3WtQWKH1e9g+A4ysExkAXXQ4l/Vm+q+l+1brMmA4n9MwUN7v9I0lDYAPdnQ/TUzJJi3zIdBJxBTnl6tHUJ2srqvFELrLNFrwrZiXEtEBVkEI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853405751699.3004744546138; Mon, 18 May 2020 18:56:45 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUV-0000Jr-VI; Tue, 19 May 2020 01:56:23 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUU-0000J6-M4 for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:22 +0000 Received: from mail-qv1-xf43.google.com (unknown [2607:f8b0:4864:20::f43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e5779618-9973-11ea-b9cf-bc764e2007e4; Tue, 19 May 2020 01:56:03 +0000 (UTC) Received: by mail-qv1-xf43.google.com with SMTP id p4so5758081qvr.10 for ; Mon, 18 May 2020 18:56:03 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:02 -0700 (PDT) X-Inumbo-ID: e5779618-9973-11ea-b9cf-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e8TO7h61vMYwatja+1Xk6Uhtwz9m20nO7NIF4kE+skE=; b=BbRKeWSCviRUxAOA+eUdGqw6Y1cC5Wj/I2lE3fY6GiPOHoRcmI9EK6t1z21Rrn1nJu LHmg+mAbJ4GIVD/vBzQeXvHxi5lt6lUEcyj/deZ+h9nL2VeUZrXC+15t18IoPSjmgtcG NSVmzIR/ONrICz7UVWB7iodUK/M4XToSxwUX8GTiLtjOKRGvy5PUke3nNB4Lx2zWco6h +8KithsI9L4Kof0lW5iOrE0Hlu1vtnKyyn94fHZ9GMRcJHdqsMhXcliHgj0CUVT1IpHc ++bop7pplnhGfZ01OKW1nqHbhj8UKYIABX6ZHagwTPTHkSB7BdwT+OqEbIr4TGYd7Ooz pq0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e8TO7h61vMYwatja+1Xk6Uhtwz9m20nO7NIF4kE+skE=; b=K6M2YjjVeeZfqVVrwbXmnyk7nZL1PvedCbLr3mZ/437/JnbqH0yV11cV+FOc6QhwX7 oHMwgCNtwl6Xl5T4/13h1tOZErcQJqxuulTkuT7s+5SfIF1daqY3eYDlZuSzkKsEGyR4 iGLbUg93m2HsV8eWte/jgnJzKNmSbhz6vQpZ1TCNH7NWnUjxXyc9mNjp/2TB7Nm6rjkB QTlmxmc2HiHy4tX79iK0H/4ALoApQdkoOHKfaY1psCUz8numG3PyuxYMDSIW2y/3A7bL pdFX1iNuWiuodp9TrXtfl8Zn2vpB5OZkZa8t1DBItkC4HrdhnpfRSBEFM18WAcTbIQHr XJnA== X-Gm-Message-State: AOAM530qgC4LVt0c1nE6wI9mbHzdiGqOp2VyAusuS1OI1NlwBOaafVhW hSFr7OfPYNtaGvpXDfl1CfPY9Aj3 X-Google-Smtp-Source: ABdhPJzbpjWOrcqmflQcR6E22gVQ4L4bxyt56htHAEFEX8VD8vIJ5q+gINX5KbokM7bGs0s+AcO3yA== X-Received: by 2002:ad4:4b61:: with SMTP id m1mr19597825qvx.235.1589853363185; Mon, 18 May 2020 18:56:03 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 07/19] libxl: write qemu arguments into separate xenstore keys Date: Mon, 18 May 2020 21:54:51 -0400 Message-Id: <20200519015503.115236-8-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Wei Liu , Jason Andryuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki This allows using arguments with spaces, like -append, without nominating any special "separator" character. Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Jason Andryuk Write arguments in dm-argv directory instead of overloading mini-os's dmargs string. Make libxl__write_stub_dmargs vary behaviour based on the is_linux_stubdom flag. Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v3: - previous version of this patch "libxl: use \x1b to separate qemu arguments for linux stubdomain" used specific non-printable separator, but it was rejected as xenstore doesn't cope well with non-printable chars Changes in v6: - Re-work to use libxl__xs_ functions in a loop. - Drop rtc/timeoffset Changes in v7: - Use a single function with an is_linux_stubdom flag. Signed-off-by: Jason Andryuk --- tools/libxl/libxl_dm.c | 77 +++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 8e57cd8c1f..23b13f84d2 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2068,13 +2068,11 @@ static int libxl__vfb_and_vkb_from_hvm_guest_config= (libxl__gc *gc, =20 static int libxl__write_stub_dmargs(libxl__gc *gc, int dm_domid, int guest_domid, - char **args) + char **args, bool is_linux_stubdom) { - int i; - char *dmargs; - int dmargs_size; struct xs_permissions roperm[2]; xs_transaction_t t =3D XBT_NULL; + char *dmargs; int rc; =20 roperm[0].id =3D 0; @@ -2082,22 +2080,27 @@ static int libxl__write_stub_dmargs(libxl__gc *gc, roperm[1].id =3D dm_domid; roperm[1].perms =3D XS_PERM_READ; =20 - i =3D 0; - dmargs_size =3D 0; - while (args[i] !=3D NULL) { - dmargs_size =3D dmargs_size + strlen(args[i]) + 1; - i++; - } - dmargs_size++; - dmargs =3D (char *) libxl__malloc(gc, dmargs_size); - i =3D 1; - dmargs[0] =3D '\0'; - while (args[i] !=3D NULL) { - if (strcmp(args[i], "-sdl") && strcmp(args[i], "-M") && strcmp(arg= s[i], "xenfv")) { - strcat(dmargs, " "); - strcat(dmargs, args[i]); + if (!is_linux_stubdom) { + int dmargs_size =3D 0; + int i =3D 0; + + while (args[i] !=3D NULL) { + dmargs_size =3D dmargs_size + strlen(args[i]) + 1; + i++; + } + + dmargs_size++; + dmargs =3D (char *) libxl__malloc(gc, dmargs_size); + + i =3D 1; + dmargs[0] =3D '\0'; + while (args[i] !=3D NULL) { + if (strcmp(args[i], "-sdl") && strcmp(args[i], "-M") && strcmp= (args[i], "xenfv")) { + strcat(dmargs, " "); + strcat(dmargs, args[i]); + } + i++; } - i++; } =20 for (;;) { @@ -2113,17 +2116,33 @@ static int libxl__write_stub_dmargs(libxl__gc *gc, &vm_path); if (rc) goto out; =20 - path =3D GCSPRINTF("%s/image/dmargs", vm_path); + if (is_linux_stubdom) { + int i; =20 - rc =3D libxl__xs_mknod(gc, t, path, roperm, ARRAY_SIZE(roperm)); - if (rc) goto out; + path =3D GCSPRINTF("%s/image/dm-argv", vm_path); =20 - rc =3D libxl__xs_write_checked(gc, t, path, dmargs); - if (rc) goto out; + rc =3D libxl__xs_mknod(gc, t, path, roperm, ARRAY_SIZE(roperm)= ); + if (rc) goto out; =20 - rc =3D libxl__xs_mknod(gc, t, GCSPRINTF("%s/rtc/timeoffset", vm_pa= th), - roperm, ARRAY_SIZE(roperm)); - if (rc) goto out; + for (i=3D1; args[i] !=3D NULL; i++) { + rc =3D libxl__xs_write_checked(gc, t, + GCSPRINTF("%s/%03d", path, i), + args[i]); + if (rc) goto out; + } + } else { + path =3D GCSPRINTF("%s/image/dmargs", vm_path); + + rc =3D libxl__xs_mknod(gc, t, path, roperm, ARRAY_SIZE(roperm)= ); + if (rc) goto out; + + rc =3D libxl__xs_write_checked(gc, t, path, dmargs); + if (rc) goto out; + + rc =3D libxl__xs_mknod(gc, t, GCSPRINTF("%s/rtc/timeoffset", v= m_path), + roperm, ARRAY_SIZE(roperm)); + if (rc) goto out; + } =20 rc =3D libxl__xs_transaction_commit(gc, &t); if (!rc) break; @@ -2298,7 +2317,9 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stu= b_dm_spawn_state *sdss) =20 libxl__store_libxl_entry(gc, guest_domid, "dm-version", libxl_device_model_version_to_string(dm_config->b_info.device_mode= l_version)); - libxl__write_stub_dmargs(gc, dm_domid, guest_domid, args); + + libxl__write_stub_dmargs(gc, dm_domid, guest_domid, args, + libxl__stubdomain_is_linux(&guest_config->b_i= nfo)); libxl__xs_printf(gc, XBT_NULL, GCSPRINTF("%s/image/device-model-domid", libxl__xs_get_dompath(gc, guest_domid)), --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853416; cv=none; d=zohomail.com; s=zohoarc; b=MV/hKnK5zIziEeI1k6j6PlUnDxjcMgOmEpT7ptzF5jil5TiEYhtzLbfpnJIStPlxWfLFZfJ7UOOL3Y8vPy2RqJ4TJfNn+2YTEFxgJqZ/TsHPPzU9zrVJFk03WkpxNytUwpvjkFRpzRnlhmumIlAf113LjfaFmPRqi3KmndSbvXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853416; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZT6l/MiPRcZkFyWjFyjLysM4bTyEFRemlpKKfgP53K8=; b=cr/NKDcf1vKng4QMunCzzXiqFL/Zil5T5BbAWBbsBkJQPlJxA0jG+VKCD9OyDn/IJjTk/cYHI1WQ1zj09ooTwNgj+g2uZkzLCLBWpHyWtBqOOmC2tiR4Mv02itdjeVoovv8dOxiKjD3nZCyGx+NkyFOYHrGmRIQHYXtCjktpRRo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853416953831.8935736373602; Mon, 18 May 2020 18:56:56 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUa-0000MB-8p; Tue, 19 May 2020 01:56:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUZ-0000Lm-LB for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:27 +0000 Received: from mail-qt1-x843.google.com (unknown [2607:f8b0:4864:20::843]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e6b5a40c-9973-11ea-b07b-bc764e2007e4; Tue, 19 May 2020 01:56:05 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id i68so9932464qtb.5 for ; Mon, 18 May 2020 18:56:05 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:04 -0700 (PDT) X-Inumbo-ID: e6b5a40c-9973-11ea-b07b-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZT6l/MiPRcZkFyWjFyjLysM4bTyEFRemlpKKfgP53K8=; b=elFKmU6j1ZIgLTmzjkhpJNbOoioOo6j4hHBYLYVKWNLIKoUfKkWwNOyzBwTNZzMsE3 0uQ2ZTwcBrb/5S6D6DriuLMgGxkw1Lg16ggD5ixEVJbM8EST+KqV1t5SKs/kn6ZW+6yk HK0OjfDxefp9oQjhqEq96e7SfklGRsuk2fGHjiQW4+gphweYkIWtXYuQYyUb7hR/sDZf EfRWr/gRoAe7ivWx00ulFrs011sgQcPNRPmESUeMp39/avS65UUGKLXCt5RfXQhY7FSv EcMW68Q0PeDvXsXqKBRkLO/8QOkqSliQo8RKLIyAt04Bmjg1VJotdjzbX4R8pQyCHpHN gQwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZT6l/MiPRcZkFyWjFyjLysM4bTyEFRemlpKKfgP53K8=; b=K436gOrqTF2qbHgFB7igmSrM2arDYpSkcwbMNotVPP9Sq5N8gRD3uX2/2/V+03DXEn oPeZjsIOYGoWfvkyq7/DWwvPP7qQPbI4AWQXqQoc+YI3Lf2QwGuC+Slr93Mv69mPQwnc GBvL2F6p6o/eDBXyicoJDUgEfNeC/zS/SjUn0NRIx664aGGE0P2LEtTHBRTvYm4ESZeU 9fWVEynSRdE770MnAqa14+f5W3IQb4bAee14nu5EvCHO47hybA+7Lu1COXdjUysBtmCA w+lf9tkm8lJWV90oxWQ9mF4enWq6QWWVpHlUxXGsvrl8l7cH7wbq9LiLM6jM3XVMM0y/ 4mjQ== X-Gm-Message-State: AOAM532/q/TUiUJPT9GGUDEFBy6Tqw0GUcXbJCMgkvEfhi50V9EIiCvH TsqpYwNZ0imWZTtwyU8pDq3MvP0j X-Google-Smtp-Source: ABdhPJw7/9pM01IxlvHjRpZwT4cZjgA1vimz24Bp/lBjrL4XAKBw5ShvSMBRufnCcwYHiw1phAQqsw== X-Received: by 2002:ac8:1aab:: with SMTP id x40mr19875411qtj.358.1589853365283; Mon, 18 May 2020 18:56:05 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 08/19] xl: add stubdomain related options to xl config parser Date: Mon, 18 May 2020 21:54:52 -0400 Message-Id: <20200519015503.115236-9-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Jason Andryuk , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Anthony PERARD , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Jason Andryuk Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v6: - Add Acked-by: Ian Jackson --- docs/man/xl.cfg.5.pod.in | 27 +++++++++++++++++++++++---- tools/xl/xl_parse.c | 7 +++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 0e9e58a41a..c9bc181a95 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2733,10 +2733,29 @@ model which they were installed with. =20 =3Ditem B =20 -Override the path to the binary to be used as the device-model. The -binary provided here MUST be consistent with the -B which you have specified. You should not -normally need to specify this option. +Override the path to the binary to be used as the device-model running in +toolstack domain. The binary provided here MUST be consistent with the +B which you have specified. You should not normally = need +to specify this option. + +=3Ditem B + +Override the path to the kernel image used as device-model stubdomain. +The binary provided here MUST be consistent with the +B which you have specified. +In case of B it is expected to be MiniOS-based stubd= omain +image, in case of B it is expected to be Linux-based stubdomain +kernel. + +=3Ditem B + +Override the path to the ramdisk image used as device-model stubdomain. +The binary provided here is to be used by a kernel pointed by B. +It is known to be used only by Linux-based stubdomain kernel. + +=3Ditem B + +Start the stubdomain with MBYTES megabytes of RAM. Default is 128. =20 =3Ditem B =20 diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 4450d59f16..61b4ef7b7e 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2525,6 +2525,13 @@ skip_usbdev: xlu_cfg_replace_string(config, "device_model_user", &b_info->device_model_user, 0); =20 + xlu_cfg_replace_string (config, "stubdomain_kernel", + &b_info->stubdomain_kernel, 0); + xlu_cfg_replace_string (config, "stubdomain_ramdisk", + &b_info->stubdomain_ramdisk, 0); + if (!xlu_cfg_get_long (config, "stubdomain_memory", &l, 0)) + b_info->stubdomain_memkb =3D l * 1024; + #define parse_extra_args(type) \ e =3D xlu_cfg_get_list_as_string_list(config, "device_model_args"#type= , \ &b_info->extra##type, 0); \ --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853417; cv=none; d=zohomail.com; s=zohoarc; b=BBACRZpxyoEh6EZrO972IfUR0VC7PrpaYOoOeIxKSv2uKsCOKhex+LHhmO7upi9FvFxrCS3vYhdXXnN7MmvVqjHJ1U/ePH/BBttyFnkI6Qf0aL+FkLBxsev/wGl2La679iyI6C2q4qrdfXrXrGqlcxu4d72yqGEpVQT2Ukpb/e8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853417; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2CXxR3/fu54dMwhCVd1DE62O7N45m5o1SIg5x3dwKzg=; b=c7k/yAOi1ahauyIr1vRrzEXw0BKwZ/KNOqFJshGB0rI43opVifcyewbstQ8nlOJ3gEYCt4pT38nHsndBiixFV3TOqkaiNr5CFst/ec/7A15qViGutaX1OTYzPG7QrkCatwQWW1EHp6wtbTwKKOfz7lJnhHn0ABCdOvfcksw0oeQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853417370339.5940311340905; Mon, 18 May 2020 18:56:57 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUf-0000Qo-JO; Tue, 19 May 2020 01:56:33 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUe-0000Q1-M7 for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:32 +0000 Received: from mail-qv1-xf42.google.com (unknown [2607:f8b0:4864:20::f42]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e79c0834-9973-11ea-9887-bc764e2007e4; Tue, 19 May 2020 01:56:07 +0000 (UTC) Received: by mail-qv1-xf42.google.com with SMTP id d1so5777994qvl.6 for ; Mon, 18 May 2020 18:56:07 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:06 -0700 (PDT) X-Inumbo-ID: e79c0834-9973-11ea-9887-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2CXxR3/fu54dMwhCVd1DE62O7N45m5o1SIg5x3dwKzg=; b=AKhBNPAcoTZToHpSRZE5KrTgrDLx7XfXdXFxBJNg7lYrrzSOzsoWnKqqFozWnmA9Cl n2peygGD3HfXEuDgP9E/gTEK23cgcDdGCtmZD8H7nypC8v571/5mZ1vlVpsiJsocOx9U w+Gx58vsJOSJS3foDSvkIg8MV1zlNjYoXbsmJvVBS5Hx39kEbaI9A/pD8bjuMFxrbjXv FIimCXiDuUZAsTPMFNLXQiW1z+HkqHKYZWzQxF1cza4zQ6qem47RYV37cGLYTFeHcejJ RjwhHpwmqUVlwIbD6hBx0cEEfO55YJAjrbIS8OgISFfGcPIhySXFb8ttHD/1MWOKwJCl Gc6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2CXxR3/fu54dMwhCVd1DE62O7N45m5o1SIg5x3dwKzg=; b=QuByHL+9D6da2fLBtQy6KVBJbcaoPmIYuntABZftdpevoI4xzkLU0qaAmJY4bOYBpR hWlewhLZs4UtUcyF7haxjZHTLAHnbrTEzSxzCQIiaZjAC/RAVCOwzWh51OIjJ73/SXYU MhD0Du5Hpy0IRwwr50UCWwaBzVKsJ3TiAHWzrYGsm97jZoqyJIbTwpU0qjleSg/oBmYt RJjOFJGIeq6x3Tdd7CFe8XPDxBs4ktp2BK6vJeuQpALnKtQgnYLWste/fE0wtnZYBkWb IGh4F8FR4lgHYbDm6xiGb9qXB2cjohkPUc2i2FJgPYssw6GhSUBbtsHsTLBMRuUIIrbu hdrA== X-Gm-Message-State: AOAM531HYCwyDq57XPemDZqnBuVYU1k+tBAlbGdabeuUA5NnTreUHsdN aAQZ71JvgK6bAu1co7oEiokMMcVg X-Google-Smtp-Source: ABdhPJwTXzjvx4qmTPZqyVC7gX6iM1nyvCSo9BTAgYUCX/xOWafExMXAS2HimiKJ/82sLt8AVE7eIw== X-Received: by 2002:a0c:b5c4:: with SMTP id o4mr18315483qvf.229.1589853366849; Mon, 18 May 2020 18:56:06 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 09/19] tools/libvchan: notify server when client is connected Date: Mon, 18 May 2020 21:54:53 -0400 Message-Id: <20200519015503.115236-10-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Jason Andryuk , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Ian Jackson , Daniel De Graaf Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Let the server know when the client is connected. Otherwise server will notice only when client send some data. This change does not break existing clients, as libvchan user should handle spurious notifications anyway (for example acknowledge of remote side reading the data). Cc: Daniel De Graaf Signed-off-by: Marek Marczykowski-G=C3=B3recki Replace spaces with tabs to match the file's whitespace. Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Marek: I had this patch in Qubes for a long time and totally forgot it wasn't upstream thing... Changes in v6: - Add Acked-by: Ian Jackson - CC Daniel De Graaf --- tools/libvchan/init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/libvchan/init.c b/tools/libvchan/init.c index 180833dc2f..ad4b64fbe3 100644 --- a/tools/libvchan/init.c +++ b/tools/libvchan/init.c @@ -447,6 +447,9 @@ struct libxenvchan *libxenvchan_client_init(struct xent= oollog_logger *logger, ctrl->ring->cli_live =3D 1; ctrl->ring->srv_notify =3D VCHAN_NOTIFY_WRITE; =20 + /* wake up the server */ + xenevtchn_notify(ctrl->event, ctrl->event_port); + out: if (xs) xs_daemon_close(xs); --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853424; cv=none; d=zohomail.com; s=zohoarc; b=n7fZdoOf24emA2obstCCG5EZIMbm5Ihygl/p2DUj49Q0BTXV5nmIUK5nDi8PA+VfhIkt/Myicdy7IO2HI3sKhMtGHOxX0xR8AIJrk+rmB2vaiY1Pne4LxhBauFyNxjHJlSf5By9KYsEdBtPXYJEw/CNG9sRWYgo3kz9EODqqhcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853424; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DwiumbG1d5HPUMbypCrL3Y7aDy+PWG/BBSK4eFZuL7c=; b=YXuEG3343Azo4igr3fEZfSF02QjoBb4LFPopfBofcJQKhwLTbyu3XAD3HF3FqdicVYRoBi06CueMup7t+F/z/GClHJpzyKHvYhv+LLxnxNarmm0EEhwUIPXtKLeortgtoOuWml4DvUmlonDxeQw57ogQXxyHdjhrYCWvOc0U1ss= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853424053716.4491681477425; Mon, 18 May 2020 18:57:04 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUk-0000Ut-TA; Tue, 19 May 2020 01:56:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUj-0000U6-Mf for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:37 +0000 Received: from mail-qv1-xf43.google.com (unknown [2607:f8b0:4864:20::f43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e8bc7762-9973-11ea-b9cf-bc764e2007e4; Tue, 19 May 2020 01:56:09 +0000 (UTC) Received: by mail-qv1-xf43.google.com with SMTP id ee19so5764152qvb.11 for ; Mon, 18 May 2020 18:56:09 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:07 -0700 (PDT) X-Inumbo-ID: e8bc7762-9973-11ea-b9cf-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DwiumbG1d5HPUMbypCrL3Y7aDy+PWG/BBSK4eFZuL7c=; b=HP50HwP5r9rPIbd3fqfL3tTThoVI/3hE8NBtNP1oUlu9aflUHXGpge2DVqiibaFKWY PAKCUtOmAiOx7Oyr0ni4tcYHlhmGUrfZ3h3JDCMH7/pRVT/1bBHQlmc2q+NtPQw/vWZw W+TjANEOrODFwC8Ty8aKslnz3Yt/2zDl+Wp4mUhje0M+zxpRMD27PodPG8S4ewgKYnu3 vp5B2t2pBpVM88iC37oLAtOUGZ0PsU9i+xsqnbEs9X6ewakdGa8rj8/SjA3y+itZBSO6 pxQzDFdd7LoZpwuybt3xNfaQK0LsR2Ff3+rtCU1PjRSfMFAOIWxPDr4UrkVD/vtE5mUH CM6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DwiumbG1d5HPUMbypCrL3Y7aDy+PWG/BBSK4eFZuL7c=; b=li/wTvxNTaQwC/09qaykXKVTOn1ZAjJEc0pw5v9VNy/uti0qz/xujE0SgPRm3tuhmd e1uFI98XAPtVgelRQ0W/iuAVWR6P0vRxcRQ8CQGc8VR3iLtBIT4M5eusW5Wl9HbSmiJF Ec//14oOgrM/yFL9RPWnxj1fhWeXVMqeB4xmuSZwgm94iiBpK4OLVvlIgHM4lViqFbOT CENjJLDNUari/kqL+X6kv4py60ROCwAh4mqt92druz8a83X84AjbaB2W2V52Ag8sc42R J0YPKIdHsx+tgAnsmwSQX3IgwvY6Qi7gUB6IjtPvcXWq38skLtSwTgleYAxwfmjo8v39 Vmpw== X-Gm-Message-State: AOAM530Wz7jX191vnzORfu5/xZwL+deJ4oqBBKOcjQW6268JSbjNRCLI L0y160BR0RlvWhD7lFvHQ8SDj1DQ X-Google-Smtp-Source: ABdhPJyGiSspDHrCA+s+ebMsuUXIQo8PhwHiSDhkYeC6N9s5pn5WX8CTsITCm8K3oroBjBUfaU3LsA== X-Received: by 2002:a0c:e403:: with SMTP id o3mr17895876qvl.24.1589853368702; Mon, 18 May 2020 18:56:08 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 10/19] libxl: add save/restore support for qemu-xen in stubdomain Date: Mon, 18 May 2020 21:54:54 -0400 Message-Id: <20200519015503.115236-11-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Jason Andryuk , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Anthony PERARD , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Rely on a wrapper script in stubdomain to attach relevant consoles to qemu. The save console (1) must be attached to fdset/1. When performing a restore, $STUBDOM_RESTORE_INCOMING_ARG must be replaced on the qemu command line by "fd:$FD", where $FD is an open file descriptor number to the restore console (2). Signed-off-by: Marek Marczykowski-G=C3=B3recki Address TODO in dm_state_save_to_fdset: Only remove savefile for non-stubdom. Use $STUBDOM_RESTORE_INCOMING_ARG instead of fd:3 and update commit message. Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v3: - adjust for qmp_ev* - assume specific fdset id in qemu set in stubdomain Changes in v5: - Only remove savefile for non-stubdom Changes in v6: - Replace hardcoded fd:3 with placeholder $STUBDOM_RESTORE_INCOMING_ARG Changes in v7 - Added Acked-by: Ian Jackson --- tools/libxl/libxl_dm.c | 25 +++++++++++++------------ tools/libxl/libxl_qmp.c | 27 +++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 23b13f84d2..62d0d46c98 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1745,10 +1745,19 @@ static int libxl__build_device_model_args_new(libxl= __gc *gc, } =20 if (state->saved_state) { - /* This file descriptor is meant to be used by QEMU */ - *dm_state_fd =3D open(state->saved_state, O_RDONLY); - flexarray_append(dm_args, "-incoming"); - flexarray_append(dm_args, GCSPRINTF("fd:%d",*dm_state_fd)); + if (is_stubdom) { + /* Linux stubdomain must replace $STUBDOM_RESTORE_INCOMING_ARG + * with the approriate fd:$num argument for the + * STUBDOM_CONSOLE_RESTORE console 2. + */ + flexarray_append(dm_args, "-incoming"); + flexarray_append(dm_args, "$STUBDOM_RESTORE_INCOMING_ARG"); + } else { + /* This file descriptor is meant to be used by QEMU */ + *dm_state_fd =3D open(state->saved_state, O_RDONLY); + flexarray_append(dm_args, "-incoming"); + flexarray_append(dm_args, GCSPRINTF("fd:%d",*dm_state_fd)); + } } for (i =3D 0; b_info->extra && b_info->extra[i] !=3D NULL; i++) flexarray_append(dm_args, b_info->extra[i]); @@ -2227,14 +2236,6 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__st= ub_dm_spawn_state *sdss) =20 assert(libxl_defbool_val(guest_config->b_info.device_model_stubdomain)= ); =20 - if (libxl__stubdomain_is_linux(&guest_config->b_info)) { - if (d_state->saved_state) { - LOG(ERROR, "Save/Restore not supported yet with Linux Stubdom.= "); - ret =3D -1; - goto out; - } - } - sdss->pvqemu.guest_domid =3D INVALID_DOMID; =20 libxl_domain_create_info_init(&dm_config->c_info); diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index efaba91086..c394000ea9 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -962,6 +962,7 @@ static void dm_stopped(libxl__egc *egc, libxl__ev_qmp *= ev, const libxl__json_object *response, int rc); static void dm_state_fd_ready(libxl__egc *egc, libxl__ev_qmp *ev, const libxl__json_object *response, int rc); +static void dm_state_save_to_fdset(libxl__egc *egc, libxl__ev_qmp *ev, int= fdset); static void dm_state_saved(libxl__egc *egc, libxl__ev_qmp *ev, const libxl__json_object *response, int rc); =20 @@ -994,10 +995,17 @@ static void dm_stopped(libxl__egc *egc, libxl__ev_qmp= *ev, EGC_GC; libxl__domain_suspend_state *dsps =3D CONTAINER_OF(ev, *dsps, qmp); const char *const filename =3D dsps->dm_savefile; + uint32_t dm_domid =3D libxl_get_stubdom_id(CTX, dsps->domid); =20 if (rc) goto error; =20 + if (dm_domid) { + /* see Linux stubdom interface in docs/stubdom.txt */ + dm_state_save_to_fdset(egc, ev, 1); + return; + } + ev->payload_fd =3D open(filename, O_WRONLY | O_CREAT, 0600); if (ev->payload_fd < 0) { LOGED(ERROR, ev->domid, @@ -1028,7 +1036,6 @@ static void dm_state_fd_ready(libxl__egc *egc, libxl_= _ev_qmp *ev, EGC_GC; int fdset; const libxl__json_object *o; - libxl__json_object *args =3D NULL; libxl__domain_suspend_state *dsps =3D CONTAINER_OF(ev, *dsps, qmp); =20 close(ev->payload_fd); @@ -1043,6 +1050,21 @@ static void dm_state_fd_ready(libxl__egc *egc, libxl= __ev_qmp *ev, goto error; } fdset =3D libxl__json_object_get_integer(o); + dm_state_save_to_fdset(egc, ev, fdset); + return; + +error: + assert(rc); + libxl__remove_file(gc, dsps->dm_savefile); + dsps->callback_device_model_done(egc, dsps, rc); +} + +static void dm_state_save_to_fdset(libxl__egc *egc, libxl__ev_qmp *ev, int= fdset) +{ + EGC_GC; + int rc; + libxl__json_object *args =3D NULL; + libxl__domain_suspend_state *dsps =3D CONTAINER_OF(ev, *dsps, qmp); =20 ev->callback =3D dm_state_saved; =20 @@ -1060,7 +1082,8 @@ static void dm_state_fd_ready(libxl__egc *egc, libxl_= _ev_qmp *ev, =20 error: assert(rc); - libxl__remove_file(gc, dsps->dm_savefile); + if (!libxl_get_stubdom_id(CTX, dsps->domid)) + libxl__remove_file(gc, dsps->dm_savefile); dsps->callback_device_model_done(egc, dsps, rc); } =20 --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853426; cv=none; d=zohomail.com; s=zohoarc; b=HMd6vauUvTiYuD5sFV7b130N3QCUIyiUFREsOcHj3QxqyHtD5hws3RrQzDpMd+ij7YPaYES/nE90QxRAoAuYHv3/alBgtXRH3qOvNxPNwfGbwgU19fbniBZz7btNCi7iQKr6kFO009yyUr7TaFPGJocz9TMQ79tGfvv6RyYJRKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853426; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=67muXVTuajJEPjuiVYNz+RE396Rty6mUCKX18cQDly8=; b=a9GAGkOnHWGpjiUnSfr9xm+KOj81NWLTq3z5CYeTYhz//axVvuy6JdkS8A/kN+MsMyRi6LvqurppYB9nf8aKTEJ/nzkmFRYgQRJtPLe74MmLfCDTsvia+jTrZ+o1dBJTIVRSNW/FMOPTOSS/vu1ULJsJagWGzRqdgxSHutcXLok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853426712893.202915844922; Mon, 18 May 2020 18:57:06 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUp-0000Y8-9X; Tue, 19 May 2020 01:56:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUo-0000Xe-MK for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:42 +0000 Received: from mail-qv1-xf42.google.com (unknown [2607:f8b0:4864:20::f42]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e98f2748-9973-11ea-b07b-bc764e2007e4; Tue, 19 May 2020 01:56:10 +0000 (UTC) Received: by mail-qv1-xf42.google.com with SMTP id fb16so5737183qvb.5 for ; Mon, 18 May 2020 18:56:10 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:09 -0700 (PDT) X-Inumbo-ID: e98f2748-9973-11ea-b07b-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=67muXVTuajJEPjuiVYNz+RE396Rty6mUCKX18cQDly8=; b=fBhPiLx6vGxfX8RquZzoRxZDDliU6MKbftuDKBQ/hqIWz/3AJ+r8jOdcrEgX6Qlul9 2URZxy/+snCKgAtOfzAbp9+PmijswCxfGVWdZhXBMAjfTowVb2aK/ZnZVZzqrN//E7+5 qAHg4b8GhduyH4eyQ+tQWv9uSEdUgjKT/6s9hJ0/zXcqJU15gTy6wJFfB0DJV3HojOqy 01RRG1x3y3iuOD4r+yEDNyrYOB4MPxsfZUuZ2pYSAgoc4MNuUlQl8poyupqNwP4BEElw yyDTC/eaib/pmo7bivFMu32MyyjqKWqw8aziMiTNd69vIKwLSuwDZ95N+M4t0GAukk+x Il/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=67muXVTuajJEPjuiVYNz+RE396Rty6mUCKX18cQDly8=; b=Ox9ApQvLabky7vgL6y4k+hYtlnuniTYfZuqtVIwneWstGqqXH+LgMlXG6RL5AspPx2 YRH1j7hPwkkRxauUwkGxQkiBdeOpgn6G3TaHRAXWH77tcs08er2hAFQTpg8/yo8AJacK KrYSUCQakoXl00zyJsZWnGcirEtzGyafg+J+rn6xx2sukC6E7oSWPgLYpb9peG3P2eHP QWXZrpShvm36EMxurh3MyuyFnW1GWcHkoNOnG5U37SNKBiWIiAz3lkUVOHm82nph1ot3 3V5lleDN6ioAt5+oD28IB5/RvH78Xoks+iXSLIH7aUtF+8HOMNAN5vGHLlUz2AIkOFUR Yqtw== X-Gm-Message-State: AOAM532nonNWXicP+UWt/MZRZL2Sk2eqiREiEBkrODnV/X9nSHGRqgdE xRfu/grYSnaODU0Pc8keSzJlM3ox X-Google-Smtp-Source: ABdhPJxvCLHrLRHDGiZ2w3ADAvYvBlO5SG181DgeU83f4KwNeDp8MsclnwQltBEYw30Yz14dq2Jzgg== X-Received: by 2002:ad4:5506:: with SMTP id az6mr17650121qvb.136.1589853370138; Mon, 18 May 2020 18:56:10 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 11/19] tools: add missing libxenvchan cflags Date: Mon, 18 May 2020 21:54:55 -0400 Message-Id: <20200519015503.115236-12-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Wei Liu , Jason Andryuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki libxenvchan.h include xenevtchn.h and xengnttab.h, so applications built with it needs applicable -I in CFLAGS too. Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Jason Andryuk Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v6 - Add Acked-by: Ian Jackson --- tools/Rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Rules.mk b/tools/Rules.mk index 5b8cf748ad..59c72e7a88 100644 --- a/tools/Rules.mk +++ b/tools/Rules.mk @@ -157,7 +157,7 @@ SHDEPS_libxenstat =3D $(SHLIB_libxenctrl) $(SHLIB_libx= enstore) LDLIBS_libxenstat =3D $(SHDEPS_libxenstat) $(XEN_LIBXENSTAT)/libxenstat$(= libextension) SHLIB_libxenstat =3D $(SHDEPS_libxenstat) -Wl,-rpath-link=3D$(XEN_LIBXEN= STAT) =20 -CFLAGS_libxenvchan =3D -I$(XEN_LIBVCHAN) +CFLAGS_libxenvchan =3D -I$(XEN_LIBVCHAN) $(CFLAGS_libxengnttab) $(CFLAGS_l= ibxenevtchn) SHDEPS_libxenvchan =3D $(SHLIB_libxentoollog) $(SHLIB_libxenstore) $(SHLIB= _libxenevtchn) $(SHLIB_libxengnttab) LDLIBS_libxenvchan =3D $(SHDEPS_libxenvchan) $(XEN_LIBVCHAN)/libxenvchan$(= libextension) SHLIB_libxenvchan =3D $(SHDEPS_libxenvchan) -Wl,-rpath-link=3D$(XEN_LIBVC= HAN) --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853441; cv=none; d=zohomail.com; s=zohoarc; b=mF1wILuS2s84PwIZZTk6FxaZhNBBAz9vqZLDLxVCIoUGWqWQJYPJ+G5WHtyMLd1qRn02f/aJrhRwxJYV3DAqGsh1F1zC/7CTOwHjzLdBsfzKtlj9ubI9sUGAWZmEkcTUhlvRFHoYi5eTstud3L1A03aJFgjyYIO0ZsHxizP7rYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853441; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kEXkWybJoTWgEbRxoPRBV+0UyHS+McZIDFYoiINJxvs=; b=XKEd8sea3RfoR7IazRub6NwaIByt6Ah8jhtVSMvcAmtH9ylMzH8lT+7Qqey7U1h8pBEqduPOLSr92CJaAcr1qaxi2+Sd+1lwrL3UobfdFwW6wv5cC9aQOrIVwyzhQVAHfzeJPzSE8JyQUCicfpT4syVXonlp0VUI+JggMTl+dvQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853441003338.9541494168768; Mon, 18 May 2020 18:57:21 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUu-0000cP-L3; Tue, 19 May 2020 01:56:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUt-0000bb-Ma for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:47 +0000 Received: from mail-qv1-xf31.google.com (unknown [2607:f8b0:4864:20::f31]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ead05370-9973-11ea-b07b-bc764e2007e4; Tue, 19 May 2020 01:56:12 +0000 (UTC) Received: by mail-qv1-xf31.google.com with SMTP id z5so5774793qvw.4 for ; Mon, 18 May 2020 18:56:12 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:11 -0700 (PDT) X-Inumbo-ID: ead05370-9973-11ea-b07b-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kEXkWybJoTWgEbRxoPRBV+0UyHS+McZIDFYoiINJxvs=; b=qcVzo3a+KB3ETvgsQidsSXACydEgJBtJ4WRf01+VVSjp9T9U5ONXTcDLnH7KNYaw3U u/d2DHNW5pths5bKQKRRcJDRAtDQR9fbm3y7ZJRScmJmZ6erZZonn8VVpQbpkTaF0PeX bIw8Z9Nk5GjqR9TfA7M2074DUcH5UaMbJp1/1qYpnpVf0BfOmhoOS0/A+7tmQKYC1vjN SvlXClEzwm2NSOqXkKVtde4GfacnkI3i5hD8B/pLb7M9NXOxtu/Q6vogspPNfEEg9kHB lx57+Zoih+Zro+0UqpJu9xZT99FnQSrx+dvfZsf96q9IBoPqMLYYrtZxgJtTFZkaK+3f SDag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kEXkWybJoTWgEbRxoPRBV+0UyHS+McZIDFYoiINJxvs=; b=YQ5Rrf+3HSYiaWG6FsYZUyQlaGBnX/AlD8DGiFVrYNTQm13gVJzSKJae2nvdLF+RBq Xy1VuLrQvg32TIV5rZgDTYy5NBZA0rOC/InK9ih/7WgGGgAA/NowqSeNNcYytQWbepra nPPdIbkAghiyMFu0UVhzbBnNtUzQrBWzNvvUeCpwFVlTGKyQJeoy4dBmFIvGw1xEACoW ITKTOKHsXl0j95BBrD5mIPGrd0Pu51/9Vketon7fPcVfWIoSk4yxojJ9JzuvxECIROR9 BhJurQ3K0tKObOFp4yLOUv9tSmzRRlMcdwa9AHpUiIjhgg6I6CHZH+rW+jhtSezlpuhO 2yTQ== X-Gm-Message-State: AOAM532nYYZ9CKZMlSeVrgAueYXtNjbsQzhwnq4VHjLwFGlfDEW/k31X Xd08mbF/fjqPnsShaNNipbZV1VqU X-Google-Smtp-Source: ABdhPJxRpf7O/7FOq43998l0WVEB5d3uHUdleuhp18e5E/w4QE1ZImpyheDSJV4p1ZZX9OpP3LMWhw== X-Received: by 2002:a0c:ee64:: with SMTP id n4mr18445066qvs.246.1589853371812; Mon, 18 May 2020 18:56:11 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 12/19] tools: add simple vchan-socket-proxy Date: Mon, 18 May 2020 21:54:56 -0400 Message-Id: <20200519015503.115236-13-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Wei Liu , Jason Andryuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Add a simple proxy for tunneling socket connection over vchan. This is based on existing vchan-node* applications, but extended with socket support. vchan-socket-proxy serves both as a client and as a server, depending on parameters. It can be used to transparently communicate with an application in another domian that normally expose UNIX socket interface. Specifically, it's written to communicate with qemu running within stubdom. Server mode listens for vchan connections and when one is opened, connects to a pointed UNIX socket. Client mode listens on UNIX socket and when someone connects, opens a vchan connection. Only a single connection at a time is supported. Additionally, socket can be provided as a number - in which case it's interpreted as already open FD (in case of UNIX listening socket - listen() needs to be already called). Or "-" meaning stdin/stdout - in which case it is reduced to vchan-node2 functionality. Example usage: 1. (in dom0) vchan-socket-proxy --mode=3Dclient /local/domain//data/vchan/1234 /run/qemu.(DOMID) 2. (in DOMID) vchan-socket-proxy --mode=3Dserver 0 /local/domain//data/vchan/1234 /run/qemu.(DOMID) This will listen on /run/qemu.(DOMID) in dom0 and whenever connection is made, it will connect to DOMID, where server process will connect to /run/qemu.(DOMID) there. When client disconnects, vchan connection is terminated and server vchan-socket-proxy process also disconnects from qemu. Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Jason Andryuk Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes on v5: - Ensure bindir directory is present - String and comment fixes Changes in v6 - Add Acked-by: Ian Jackson --- .gitignore | 1 + tools/libvchan/Makefile | 8 +- tools/libvchan/vchan-socket-proxy.c | 478 ++++++++++++++++++++++++++++ 3 files changed, 486 insertions(+), 1 deletion(-) create mode 100644 tools/libvchan/vchan-socket-proxy.c diff --git a/.gitignore b/.gitignore index bfa53723b3..7418ce9829 100644 --- a/.gitignore +++ b/.gitignore @@ -369,6 +369,7 @@ tools/misc/xenwatchdogd tools/misc/xen-hvmcrash tools/misc/xen-lowmemd tools/libvchan/vchan-node[12] +tools/libvchan/vchan-socket-proxy tools/ocaml/*/.ocamldep.make tools/ocaml/*/*.cm[ixao] tools/ocaml/*/*.cmxa diff --git a/tools/libvchan/Makefile b/tools/libvchan/Makefile index 7892750c3e..913bcc8884 100644 --- a/tools/libvchan/Makefile +++ b/tools/libvchan/Makefile @@ -13,6 +13,7 @@ LIBVCHAN_PIC_OBJS =3D $(patsubst %.o,%.opic,$(LIBVCHAN_OB= JS)) LIBVCHAN_LIBS =3D $(LDLIBS_libxenstore) $(LDLIBS_libxengnttab) $(LDLIBS_li= bxenevtchn) $(LIBVCHAN_OBJS) $(LIBVCHAN_PIC_OBJS): CFLAGS +=3D $(CFLAGS_libxenstore) $= (CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn) $(NODE_OBJS) $(NODE2_OBJS): CFLAGS +=3D $(CFLAGS_libxengnttab) $(CFLAGS_li= bxenevtchn) +vchan-socket-proxy.o: CFLAGS +=3D $(CFLAGS_libxenstore) $(CFLAGS_libxenctr= l) $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn) =20 MAJOR =3D 4.14 MINOR =3D 0 @@ -39,7 +40,7 @@ $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR =3D $(CURDIR) $(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL =3D $(CFLAGS_xeninclude) =20 .PHONY: all -all: libxenvchan.so vchan-node1 vchan-node2 libxenvchan.a $(PKG_CONFIG_INS= T) $(PKG_CONFIG_LOCAL) +all: libxenvchan.so vchan-node1 vchan-node2 vchan-socket-proxy libxenvchan= .a $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL) =20 libxenvchan.so: libxenvchan.so.$(MAJOR) ln -sf $< $@ @@ -59,13 +60,18 @@ vchan-node1: $(NODE_OBJS) libxenvchan.so vchan-node2: $(NODE2_OBJS) libxenvchan.so $(CC) $(LDFLAGS) -o $@ $(NODE2_OBJS) $(LDLIBS_libxenvchan) $(APPEND_LDFLA= GS) =20 +vchan-socket-proxy: vchan-socket-proxy.o libxenvchan.so + $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenvchan) $(LDLIBS_libxenstore) $(L= DLIBS_libxenctrl) $(APPEND_LDFLAGS) + .PHONY: install install: all $(INSTALL_DIR) $(DESTDIR)$(libdir) $(INSTALL_DIR) $(DESTDIR)$(includedir) + $(INSTALL_DIR) $(DESTDIR)$(bindir) $(INSTALL_PROG) libxenvchan.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir) ln -sf libxenvchan.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenvchan.s= o.$(MAJOR) ln -sf libxenvchan.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenvchan.so + $(INSTALL_PROG) vchan-socket-proxy $(DESTDIR)$(bindir) $(INSTALL_DATA) libxenvchan.h $(DESTDIR)$(includedir) $(INSTALL_DATA) libxenvchan.a $(DESTDIR)$(libdir) $(INSTALL_DATA) xenvchan.pc $(DESTDIR)$(PKG_INSTALLDIR) diff --git a/tools/libvchan/vchan-socket-proxy.c b/tools/libvchan/vchan-soc= ket-proxy.c new file mode 100644 index 0000000000..13700c5d67 --- /dev/null +++ b/tools/libvchan/vchan-socket-proxy.c @@ -0,0 +1,478 @@ +/** + * @file + * @section AUTHORS + * + * Copyright (C) 2010 Rafal Wojtczuk + * + * Authors: + * Rafal Wojtczuk + * Daniel De Graaf + * Marek Marczykowski-G=C3=B3recki + * + * @section LICENSE + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; If not, see . + * + * @section DESCRIPTION + * + * This is a vchan to unix socket proxy. Vchan server is set, and on client + * connection, local socket connection is established. Communication is bi= directional. + * One client is served at a time, clients needs to coordinate this themse= lves. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +static void usage(char** argv) +{ + fprintf(stderr, "usage:\n" + "\t%s [options] domainid nodepath [socket-path|file-no|-]\n" + "\n" + "options:\n" + "\t-m, --mode=3Dclient|server - vchan connection mode (client by d= efault)\n" + "\t-s, --state-path=3Dpath - xenstore path where write \"running\"= to \n" + "\t at startup\n" + "\t-v, --verbose - verbose logging\n" + "\n" + "client: client of a vchan connection, fourth parameter can be:\n" + "\tsocket-path: listen on a UNIX socket at this path and connect t= o vchan\n" + "\t whenever new connection is accepted;\n" + "\t handle multiple _subsequent_ connections, until te= rminated\n" + "\n" + "\tfile-no: except open FD of a socket in listen mode;\n" + "\t otherwise similar to socket-path\n" + "\n" + "\t-: open vchan connection immediately and pass the dat= a\n" + "\t from stdin/stdout; terminate when vchan connection= \n" + "\t is closed\n" + "\n" + "server: server of a vchan connection, fourth parameter can be:\n" + "\tsocket-path: connect to this UNIX socket when new vchan connect= ion\n" + "\t is accepted;\n" + "\t handle multiple _subsequent_ connections, until te= rminated\n" + "\n" + "\tfile-no: pass data to/from this FD; terminate when vchan co= nnection\n" + "\t is closed\n" + "\n" + "\t-: pass data to/from stdin/stdout; terminate when vch= an\n" + "\t connection is closed\n", + argv[0]); + exit(1); +} + +#define BUFSIZE 8192 +char inbuf[BUFSIZE]; +char outbuf[BUFSIZE]; +int insiz =3D 0; +int outsiz =3D 0; +int verbose =3D 0; + +static void vchan_wr(struct libxenvchan *ctrl) { + int ret; + + if (!insiz) + return; + ret =3D libxenvchan_write(ctrl, inbuf, insiz); + if (ret < 0) { + fprintf(stderr, "vchan write failed\n"); + exit(1); + } + if (verbose) + fprintf(stderr, "wrote %d bytes to vchan\n", ret); + if (ret > 0) { + insiz -=3D ret; + memmove(inbuf, inbuf + ret, insiz); + } +} + +static void socket_wr(int output_fd) { + int ret; + + if (!outsiz) + return; + ret =3D write(output_fd, outbuf, outsiz); + if (ret < 0 && errno !=3D EAGAIN) + exit(1); + if (ret > 0) { + outsiz -=3D ret; + memmove(outbuf, outbuf + ret, outsiz); + } +} + +static int set_nonblocking(int fd, int nonblocking) { + int flags =3D fcntl(fd, F_GETFL); + if (flags =3D=3D -1) + return -1; + + if (nonblocking) + flags |=3D O_NONBLOCK; + else + flags &=3D ~O_NONBLOCK; + + if (fcntl(fd, F_SETFL, flags) =3D=3D -1) + return -1; + + return 0; +} + +static int connect_socket(const char *path_or_fd) { + int fd; + char *endptr; + struct sockaddr_un addr; + + fd =3D strtoll(path_or_fd, &endptr, 0); + if (*endptr =3D=3D '\0') { + set_nonblocking(fd, 1); + return fd; + } + + fd =3D socket(AF_UNIX, SOCK_STREAM, 0); + if (fd =3D=3D -1) + return -1; + + addr.sun_family =3D AF_UNIX; + strncpy(addr.sun_path, path_or_fd, sizeof(addr.sun_path)); + if (connect(fd, (const struct sockaddr *)&addr, sizeof(addr)) =3D=3D -= 1) { + close(fd); + return -1; + } + + set_nonblocking(fd, 1); + + return fd; +} + +static int listen_socket(const char *path_or_fd) { + int fd; + char *endptr; + struct sockaddr_un addr; + + fd =3D strtoll(path_or_fd, &endptr, 0); + if (*endptr =3D=3D '\0') { + return fd; + } + + /* if not a number, assume a socket path */ + fd =3D socket(AF_UNIX, SOCK_STREAM, 0); + if (fd =3D=3D -1) + return -1; + + addr.sun_family =3D AF_UNIX; + strncpy(addr.sun_path, path_or_fd, sizeof(addr.sun_path)); + if (bind(fd, (const struct sockaddr *)&addr, sizeof(addr)) =3D=3D -1) { + close(fd); + return -1; + } + if (listen(fd, 5) !=3D 0) { + close(fd); + return -1; + } + + return fd; +} + +static struct libxenvchan *connect_vchan(int domid, const char *path) { + struct libxenvchan *ctrl =3D NULL; + struct xs_handle *xs =3D NULL; + xc_interface *xc =3D NULL; + xc_dominfo_t dominfo; + char **watch_ret; + unsigned int watch_num; + int ret; + + xs =3D xs_open(XS_OPEN_READONLY); + if (!xs) { + perror("xs_open"); + goto out; + } + xc =3D xc_interface_open(NULL, NULL, XC_OPENFLAG_NON_REENTRANT); + if (!xc) { + perror("xc_interface_open"); + goto out; + } + /* wait for vchan server to create *path* */ + xs_watch(xs, path, "path"); + xs_watch(xs, "@releaseDomain", "release"); + while ((watch_ret =3D xs_read_watch(xs, &watch_num))) { + /* don't care about exact which fired the watch */ + free(watch_ret); + ctrl =3D libxenvchan_client_init(NULL, domid, path); + if (ctrl) + break; + + ret =3D xc_domain_getinfo(xc, domid, 1, &dominfo); + /* break the loop if domain is definitely not there anymore, but + * continue if it is or the call failed (like EPERM) */ + if (ret =3D=3D -1 && errno =3D=3D ESRCH) + break; + if (ret =3D=3D 1 && (dominfo.domid !=3D (uint32_t)domid || dominfo= .dying)) + break; + } + +out: + if (xc) + xc_interface_close(xc); + if (xs) + xs_close(xs); + return ctrl; +} + + +static void discard_buffers(struct libxenvchan *ctrl) { + /* discard local buffers */ + insiz =3D 0; + outsiz =3D 0; + + /* discard remaining incoming data */ + while (libxenvchan_data_ready(ctrl)) { + if (libxenvchan_read(ctrl, inbuf, BUFSIZE) =3D=3D -1) { + perror("vchan read"); + exit(1); + } + } +} + +int data_loop(struct libxenvchan *ctrl, int input_fd, int output_fd) +{ + int ret; + int libxenvchan_fd; + int max_fd; + + libxenvchan_fd =3D libxenvchan_fd_for_select(ctrl); + for (;;) { + fd_set rfds; + fd_set wfds; + FD_ZERO(&rfds); + FD_ZERO(&wfds); + + max_fd =3D -1; + if (input_fd !=3D -1 && insiz !=3D BUFSIZE) { + FD_SET(input_fd, &rfds); + if (input_fd > max_fd) + max_fd =3D input_fd; + } + if (output_fd !=3D -1 && outsiz) { + FD_SET(output_fd, &wfds); + if (output_fd > max_fd) + max_fd =3D output_fd; + } + FD_SET(libxenvchan_fd, &rfds); + if (libxenvchan_fd > max_fd) + max_fd =3D libxenvchan_fd; + ret =3D select(max_fd + 1, &rfds, &wfds, NULL, NULL); + if (ret < 0) { + perror("select"); + exit(1); + } + if (FD_ISSET(libxenvchan_fd, &rfds)) { + libxenvchan_wait(ctrl); + if (!libxenvchan_is_open(ctrl)) { + if (verbose) + fprintf(stderr, "vchan client disconnected\n"); + while (outsiz) + socket_wr(output_fd); + close(output_fd); + close(input_fd); + discard_buffers(ctrl); + break; + } + vchan_wr(ctrl); + } + + if (FD_ISSET(input_fd, &rfds)) { + ret =3D read(input_fd, inbuf + insiz, BUFSIZE - insiz); + if (ret < 0 && errno !=3D EAGAIN) + exit(1); + if (verbose) + fprintf(stderr, "from-unix: %.*s\n", ret, inbuf + insiz); + if (ret =3D=3D 0) { + /* EOF on socket, write everything in the buffer and close= the + * input_fd socket */ + while (insiz) { + vchan_wr(ctrl); + libxenvchan_wait(ctrl); + } + close(input_fd); + input_fd =3D -1; + /* TODO: maybe signal the vchan client somehow? */ + break; + } + if (ret) + insiz +=3D ret; + vchan_wr(ctrl); + } + if (FD_ISSET(output_fd, &wfds)) + socket_wr(output_fd); + while (libxenvchan_data_ready(ctrl) && outsiz < BUFSIZE) { + ret =3D libxenvchan_read(ctrl, outbuf + outsiz, BUFSIZE - outs= iz); + if (ret < 0) + exit(1); + if (verbose) + fprintf(stderr, "from-vchan: %.*s\n", ret, outbuf + outsiz= ); + outsiz +=3D ret; + socket_wr(output_fd); + } + } + return 0; +} + +/** + Simple libxenvchan application, both client and server. + Both sides may write and read, both from the libxenvchan and from + stdin/stdout (just like netcat). +*/ + +static struct option options[] =3D { + { "mode", required_argument, NULL, 'm' }, + { "verbose", no_argument, NULL, 'v' }, + { "state-path", required_argument, NULL, 's' }, + { } +}; + +int main(int argc, char **argv) +{ + int is_server =3D 0; + int socket_fd =3D -1; + int input_fd, output_fd; + struct libxenvchan *ctrl =3D NULL; + const char *socket_path; + int domid; + const char *vchan_path; + const char *state_path =3D NULL; + int opt; + + while ((opt =3D getopt_long(argc, argv, "m:vs:", options, NULL)) !=3D = -1) { + switch (opt) { + case 'm': + if (strcmp(optarg, "server") =3D=3D 0) + is_server =3D 1; + else if (strcmp(optarg, "client") =3D=3D 0) + is_server =3D 0; + else { + fprintf(stderr, "invalid argument for --mode: %s\n", o= ptarg); + usage(argv); + return 1; + } + break; + case 'v': + verbose =3D 1; + break; + case 's': + state_path =3D optarg; + break; + case '?': + usage(argv); + } + } + + if (argc-optind !=3D 3) + usage(argv); + + domid =3D atoi(argv[optind]); + vchan_path =3D argv[optind+1]; + socket_path =3D argv[optind+2]; + + if (is_server) { + ctrl =3D libxenvchan_server_init(NULL, domid, vchan_path, 0, 0); + if (!ctrl) { + perror("libxenvchan_server_init"); + exit(1); + } + } else { + if (strcmp(socket_path, "-") =3D=3D 0) { + input_fd =3D 0; + output_fd =3D 1; + } else { + socket_fd =3D listen_socket(socket_path); + if (socket_fd =3D=3D -1) { + perror("listen socket"); + return 1; + } + } + } + + if (state_path) { + struct xs_handle *xs; + + xs =3D xs_open(0); + if (!xs) { + perror("xs_open"); + return 1; + } + if (!xs_write(xs, XBT_NULL, state_path, "running", strlen("running= "))) { + perror("xs_write"); + return 1; + } + xs_close(xs); + } + + for (;;) { + if (is_server) { + /* wait for vchan connection */ + while (libxenvchan_is_open(ctrl) !=3D 1) + libxenvchan_wait(ctrl); + /* vchan client connected, setup local FD if needed */ + if (strcmp(socket_path, "-") =3D=3D 0) { + input_fd =3D 0; + output_fd =3D 1; + } else { + input_fd =3D output_fd =3D connect_socket(socket_path); + } + if (input_fd =3D=3D -1) { + perror("connect socket"); + return 1; + } + if (data_loop(ctrl, input_fd, output_fd) !=3D 0) + break; + /* keep it running only when get UNIX socket path */ + if (socket_path[0] !=3D '/') + break; + } else { + /* wait for local socket connection */ + if (strcmp(socket_path, "-") !=3D 0) + input_fd =3D output_fd =3D accept(socket_fd, NULL, NULL); + if (input_fd =3D=3D -1) { + perror("accept"); + return 1; + } + set_nonblocking(input_fd, 1); + set_nonblocking(output_fd, 1); + ctrl =3D connect_vchan(domid, vchan_path); + if (!ctrl) { + perror("vchan client init"); + return 1; + } + if (data_loop(ctrl, input_fd, output_fd) !=3D 0) + break; + /* don't reconnect if output was stdout */ + if (strcmp(socket_path, "-") =3D=3D 0) + break; + + libxenvchan_close(ctrl); + ctrl =3D NULL; + } + } + return 0; +} --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853437; cv=none; d=zohomail.com; s=zohoarc; b=c8Ip7tT+l7A/MpHiGuEQUu5341Q7lYmf92XvD+jvEt0ZTVhi1pmdg0RWohvEjIe7pNAUliE7cNXIKIbix6/kSBtcnP+HyeHHprE8MXoePK6tDDw0kL7kULXyu119xoO/oIiaxjAaOcpPSiHNMpsTEY0qWiApAmnYW3REeYr0tNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853437; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SW7ozKClvM3WIhe8ybZkG6u5ih1lmHf7uAbI1XBrLpc=; b=KK5I8erFlAQsAcOeKkmTeZQxK6OLtvznc244xsi09eaYYFwrBG2IWndC88QR7X6mhTrMhJQlkjiqNGsE7TmYIC/xx5za/mqIqUmr6yV3UhxKsERix5XYYaumonoh4COd/xvKeiQSzeT6aF6EHt1CDT9+8eYvzWl4xzaI4GEuL/M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 158985343744996.74228601690425; Mon, 18 May 2020 18:57:17 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUz-0000gy-UW; Tue, 19 May 2020 01:56:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarUy-0000fm-MX for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:52 +0000 Received: from mail-qv1-xf43.google.com (unknown [2607:f8b0:4864:20::f43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id eb926a78-9973-11ea-ae69-bc764e2007e4; Tue, 19 May 2020 01:56:14 +0000 (UTC) Received: by mail-qv1-xf43.google.com with SMTP id z9so5758822qvi.12 for ; Mon, 18 May 2020 18:56:14 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:12 -0700 (PDT) X-Inumbo-ID: eb926a78-9973-11ea-ae69-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SW7ozKClvM3WIhe8ybZkG6u5ih1lmHf7uAbI1XBrLpc=; b=CnKwwadtEAFYg1zazlGc4X/IU4eFWCwKZvHufvQ1e2crzFfRNLG2+PnUTwx8Rfz/TN s4/o/YpwsIHG54JsFcb2ekxpk31n/3WxquR9sQf+0OJkXy4l39YyW1pVqRqBPxCUGg8V ps08GLBOpQfc4ztTbITjxjiMPnsSvOiNPdwKH99MSgd0Ma1EHuzAV9+UlZKKeYWfZzBU yz6aTYI8a4gXCa9IQ0v1Ci3n46ZT/cg46lqD5kq9nzp65raXWuLf7i0Kj/z0Ay6f8pEs ByVay6MQx/r4W36o+J3yD5ieVOGzWLDVs3Nnl9msX79DzHiU7X6x/nu2yuT66wvvMy26 Y80g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SW7ozKClvM3WIhe8ybZkG6u5ih1lmHf7uAbI1XBrLpc=; b=P6SRfCpPvo6ClTWrockIOjcK2zpoxpWXHl38bdDsoz044v8rooQXr/LKw5IQWMK0Zb QkdQdIrkNZVnzZhhcYp2vpc4CZzogG/Cx6POp8EWSK0h8FQd2D5AbnuJrpw7xmvBTLGa 27okBpwj2lf19GM4dTI0DBLDYDn2FhJrSuA8Om4q/HN3XJteCIWcfdi7ZDvKgr4rTsSb ApvoAQTKG9AhkuVnF5IMZXI9g1BUBbo1C42eNoMzbR1XO8XfDe/lvFIDD9lyefvj1hJb v4V7vR6a7sc/eUVCmIaxNxnOixTZp6rG5Wx26vhGyfT20lNXWhjDT6/T7A/rKntN1dcN MNag== X-Gm-Message-State: AOAM533ZOKjjmML/RqCjf1idBnMVzG8Ea2iMVxIK6X7AJVy7MPOvVets NBa0XQC6rOY3hgqbhPdQHNqJiwbn X-Google-Smtp-Source: ABdhPJxYFWLxUw/CqXdV+vgU4A067EXnFnHEE1WVte0qJKFDwTeC4vjmLzBBFixMy64+ZUjHFScS2Q== X-Received: by 2002:a0c:e48f:: with SMTP id n15mr17472904qvl.73.1589853373326; Mon, 18 May 2020 18:56:13 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 13/19] libxl: Refactor kill_device_model to libxl__kill_xs_path Date: Mon, 18 May 2020 21:54:57 -0400 Message-Id: <20200519015503.115236-14-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , Ian Jackson , Wei Liu , Jason Andryuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Move kill_device_model to libxl__kill_xs_path so we have a helper to kill a process from a pid stored in xenstore. We'll be using it to kill vchan-qmp-proxy. libxl__kill_xs_path takes a "what" string for use in printing error messages. kill_device_model is retained in libxl_dm.c to provide the string. Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v6: - Add Acked-by: Ian Jackson --- tools/libxl/libxl_aoutils.c | 32 ++++++++++++++++++++++++++++++++ tools/libxl/libxl_dm.c | 27 +-------------------------- tools/libxl/libxl_internal.h | 3 +++ 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c index 1be858c93c..c4c095a5ba 100644 --- a/tools/libxl/libxl_aoutils.c +++ b/tools/libxl/libxl_aoutils.c @@ -626,6 +626,38 @@ void libxl__kill(libxl__gc *gc, pid_t pid, int sig, co= nst char *what) what, (unsigned long)pid, sig); } =20 +/* Generic function to signal (HUP) a pid stored in xenstore */ +int libxl__kill_xs_path(libxl__gc *gc, const char *xs_path_pid, + const char *what) +{ + const char *xs_pid; + int ret, pid; + + ret =3D libxl__xs_read_checked(gc, XBT_NULL, xs_path_pid, &xs_pid); + if (ret || !xs_pid) { + LOG(ERROR, "unable to find %s pid in %s", what, xs_path_pid); + ret =3D ret ? : ERROR_FAIL; + goto out; + } + pid =3D atoi(xs_pid); + + ret =3D kill(pid, SIGHUP); + if (ret < 0 && errno =3D=3D ESRCH) { + LOG(ERROR, "%s already exited", what); + ret =3D 0; + } else if (ret =3D=3D 0) { + LOG(DEBUG, "%s signaled", what); + ret =3D 0; + } else { + LOGE(ERROR, "failed to kill %s [%d]", what, pid); + ret =3D ERROR_FAIL; + goto out; + } + +out: + return ret; +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 62d0d46c98..6829b4bdb5 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -3225,32 +3225,7 @@ out: /* Generic function to signal a Qemu instance to exit */ static int kill_device_model(libxl__gc *gc, const char *xs_path_pid) { - const char *xs_pid; - int ret, pid; - - ret =3D libxl__xs_read_checked(gc, XBT_NULL, xs_path_pid, &xs_pid); - if (ret || !xs_pid) { - LOG(ERROR, "unable to find device model pid in %s", xs_path_pid); - ret =3D ret ? : ERROR_FAIL; - goto out; - } - pid =3D atoi(xs_pid); - - ret =3D kill(pid, SIGHUP); - if (ret < 0 && errno =3D=3D ESRCH) { - LOG(ERROR, "Device Model already exited"); - ret =3D 0; - } else if (ret =3D=3D 0) { - LOG(DEBUG, "Device Model signaled"); - ret =3D 0; - } else { - LOGE(ERROR, "failed to kill Device Model [%d]", pid); - ret =3D ERROR_FAIL; - goto out; - } - -out: - return ret; + return libxl__kill_xs_path(gc, xs_path_pid, "Device Model"); } =20 /* Helper to destroy a Qdisk backend */ diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index f2f76439ec..c939557b2e 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2711,6 +2711,9 @@ int libxl__async_exec_start(libxl__async_exec_state *= aes); bool libxl__async_exec_inuse(const libxl__async_exec_state *aes); =20 _hidden void libxl__kill(libxl__gc *gc, pid_t pid, int sig, const char *wh= at); +/* kill SIGHUP a pid stored in xenstore */ +_hidden int libxl__kill_xs_path(libxl__gc *gc, const char *xs_path_pid, + const char *what); =20 /*----- device addition/removal -----*/ =20 --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853446; cv=none; d=zohomail.com; s=zohoarc; b=kVgXxgfN8jPPeKyXnnXJzpbhNFEmER4UE56klNxXGqeGyJ/tolDVvaRS8zgH9SUoBe9eM4SYZIQJsKc7URm+fzmWRyRTdicP/z4ZsCUu0vcbWqnFfHdWD4ZCeJwYsAH5GnG/SI9N1IX8EQi2A6QjBUHWiD6btyJpi0xieMbu8Ls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853446; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aLKJExg1fkxsNY3bWeg2LgROjhysCmtqf2q3X+TB4c4=; b=Y3iz8cP019ytE8mnFF2PkAp6bsSgFxOx6W+Xf9eIGzP7kg/bQXkyns6pblz0ir8ruiYyzQMhY9kgyfzUlkVZ2YGQQZEqOwsM2WxT+aaWuB9LO4vuZqqr53TIO89eUEAi1QWB2Wnwr1czu7U/4ylTao/K2sUP8o9KISbC7QVgqmY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853445998783.9437794108114; Mon, 18 May 2020 18:57:25 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarV4-0000l6-Cc; Tue, 19 May 2020 01:56:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarV3-0000kM-MW for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:56:57 +0000 Received: from mail-qv1-xf41.google.com (unknown [2607:f8b0:4864:20::f41]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ed25f18e-9973-11ea-ae69-bc764e2007e4; Tue, 19 May 2020 01:56:16 +0000 (UTC) Received: by mail-qv1-xf41.google.com with SMTP id g20so5763931qvb.9 for ; Mon, 18 May 2020 18:56:16 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:14 -0700 (PDT) X-Inumbo-ID: ed25f18e-9973-11ea-ae69-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aLKJExg1fkxsNY3bWeg2LgROjhysCmtqf2q3X+TB4c4=; b=eLtIVsO04HtNXgOxkh0x8e8blnPL2m5LxoRvrhQmeQ4l4zlhMdOU/Sq3pTKG5KCqDD WLFtMT+mAe4YrlyVY2ZTY8ESru/7Fc2dhAqMRG0yccRskZmz69urCLeUO/4iS36tILWK bx8AjOC5xO7V9BtBGx5UNiaKuDMsXCsDrUz8DiwB/QBgEqSABJdv4N61xxYy9Pi49+uG uKVnpG+QqoZJr6mlyAx/ZupphChI+8gupyW0X4XqI9Y0Mxoga20xcddXtHLklw2ko/5B s35tUtr57eYM4lI8/NhhD4JG9hnaXZD+hoZ+8qlc0hCVexihuRRCthmS2SkR4TtTi+ZK fzrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aLKJExg1fkxsNY3bWeg2LgROjhysCmtqf2q3X+TB4c4=; b=TRoN450miqFoWhUHd/FqJAvlP05I4GB/rmOnWWAQMFSRboNnL/6kLN/wiNReUdr9Ko FtcPmFbNVSzEkt0hnV/EJjjKIPYbNJmrve+pLNAXp5gFejR4jrcNqMH4Q+vJyQEQ22jJ negdKMbJDb8znKmOrmjvY4JYt5gP159i7RLuEivQZr24TlxnAcJRkUbjtvMHmkmjIyqg LW4Oho5JYcRUL1MbjijFqPpOORdytLyVscfTPDlQQcESPxYrLf9ITolGKn8QUMIRZM72 oNPB0iJe5VZMUOOZC2mWRjbYAVKLQ7xKVhTlDnoOvpz4NZVD3Volgh9LiK27BOjXicGe 3nTg== X-Gm-Message-State: AOAM531v9t+7+OaPS8t815YDOxjyc2xC/bBPfjW6U0iN6CrD0CpWP9zI tzCB4OFSra4uHnUtTuxiJjKXeKSc X-Google-Smtp-Source: ABdhPJwwsglMbjyIGgB1+ORmsHFCrULrBg2QyEZbB5t50JWgaHkG3mRuih3C4aVAzvnBPIqroiOCdQ== X-Received: by 2002:a0c:f590:: with SMTP id k16mr16653479qvm.81.1589853375426; Mon, 18 May 2020 18:56:15 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 14/19] libxl: use vchan for QMP access with Linux stubdomain Date: Mon, 18 May 2020 21:54:58 -0400 Message-Id: <20200519015503.115236-15-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Jason Andryuk , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Samuel Thibault , Anthony PERARD , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Access to QMP of QEMU in Linux stubdomain is possible over vchan connection. Handle the actual vchan connection in a separate process (vchan-socket-proxy). This simplified integration with QMP (already quite complex), but also allows preliminary filtering of (potentially malicious) QMP input. Since only one client can be connected to vchan server at the same time and it is not enforced by the libxenvchan itself, additional client-side locking is needed. It is implicitly implemented by vchan-socket-proxy, as it handle only one connection at a time. Note that qemu supports only one simultaneous client on a control socket anyway (but in UNIX socket case, it enforce it server-side), so it doesn't add any extra limitation. libxl qmp client code already has locking to handle concurrent access attempts to the same qemu qmp interface. Signed-off-by: Marek Marczykowski-G=C3=B3recki Squash in changes of regenerated autotools files. Kill the vchan-socket-proxy so we don't leak the daemonized processes. libxl__stubdomain_is_linux_running() works against the guest_domid, but the xenstore path is beneath the stubdomain. This leads to the use of libxl_is_stubdom in addition to libxl__stubdomain_is_linux_running() so that the stubdomain calls kill for the qmp-proxy. Also call libxl__qmp_cleanup() to remove the unix sockets used by vchan-socket-proxy. vchan-socket-proxy only creates qmp-libxl-$domid, and libxl__qmp_cleanup removes that as well as qmp-libxenstat-$domid. However, it tolerates ENOENT, and a stray qmp-libxenstat-$domid should not exist. Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Re-run autotools after applying. Changes in v4: - new patch, in place of both "libxl: use vchan for QMP access ..." Changes in v5: - Use device-model/%u/qmp-proxy-state xenstore path - Rephrase comment Changes in v6 - Commit message mention libxl locking - Mention re-run autotools - Squashed in re-generated autotools files - Call libxl__qmp_cleanup() to remove unix socket. - Cleanup in vchan-socket-proxy is dropped. Changes in v7 - Add Acked-by: Ian Jackson --- configure | 14 +-- docs/configure | 14 +-- stubdom/configure | 14 +-- tools/config.h.in | 3 + tools/configure | 46 ++++++---- tools/configure.ac | 9 ++ tools/libxl/libxl_dm.c | 163 +++++++++++++++++++++++++++++++++-- tools/libxl/libxl_domain.c | 10 +++ tools/libxl/libxl_internal.h | 1 + 9 files changed, 209 insertions(+), 65 deletions(-) diff --git a/configure b/configure index 9da3970cef..8af54e8a5a 100755 --- a/configure +++ b/configure @@ -644,7 +644,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -723,7 +722,6 @@ datadir=3D'${datarootdir}' sysconfdir=3D'${prefix}/etc' sharedstatedir=3D'${prefix}/com' localstatedir=3D'${prefix}/var' -runstatedir=3D'${localstatedir}/run' includedir=3D'${prefix}/include' oldincludedir=3D'/usr/include' docdir=3D'${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -976,15 +974,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=3Dyes ;; =20 - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=3Drunstatedir ;; - -runstatedir=3D* | --runstatedir=3D* | --runstatedi=3D* | --runstated=3D= * \ - | --runstate=3D* | --runstat=3D* | --runsta=3D* | --runst=3D* | --runs= =3D* \ - | --run=3D* | --ru=3D* | --r=3D*) - runstatedir=3D$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=3Dsbindir ;; -sbindir=3D* | --sbindir=3D* | --sbindi=3D* | --sbind=3D* | --sbin=3D* \ @@ -1122,7 +1111,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=3D\$$ac_var # Remove trailing slashes. @@ -1275,7 +1264,6 @@ Fine tuning of the installation directories: --sysconfdir=3DDIR read-only single-machine data [PREFIX/etc] --sharedstatedir=3DDIR modifiable architecture-independent data [PREF= IX/com] --localstatedir=3DDIR modifiable single-machine data [PREFIX/var] - --runstatedir=3DDIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=3DDIR object code libraries [EPREFIX/lib] --includedir=3DDIR C header files [PREFIX/include] --oldincludedir=3DDIR C header files for non-gcc [/usr/include] diff --git a/docs/configure b/docs/configure index 9e3ed60462..93e9dcf404 100755 --- a/docs/configure +++ b/docs/configure @@ -634,7 +634,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -711,7 +710,6 @@ datadir=3D'${datarootdir}' sysconfdir=3D'${prefix}/etc' sharedstatedir=3D'${prefix}/com' localstatedir=3D'${prefix}/var' -runstatedir=3D'${localstatedir}/run' includedir=3D'${prefix}/include' oldincludedir=3D'/usr/include' docdir=3D'${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -964,15 +962,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=3Dyes ;; =20 - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=3Drunstatedir ;; - -runstatedir=3D* | --runstatedir=3D* | --runstatedi=3D* | --runstated=3D= * \ - | --runstate=3D* | --runstat=3D* | --runsta=3D* | --runst=3D* | --runs= =3D* \ - | --run=3D* | --ru=3D* | --r=3D*) - runstatedir=3D$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=3Dsbindir ;; -sbindir=3D* | --sbindir=3D* | --sbindi=3D* | --sbind=3D* | --sbin=3D* \ @@ -1110,7 +1099,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=3D\$$ac_var # Remove trailing slashes. @@ -1263,7 +1252,6 @@ Fine tuning of the installation directories: --sysconfdir=3DDIR read-only single-machine data [PREFIX/etc] --sharedstatedir=3DDIR modifiable architecture-independent data [PREF= IX/com] --localstatedir=3DDIR modifiable single-machine data [PREFIX/var] - --runstatedir=3DDIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=3DDIR object code libraries [EPREFIX/lib] --includedir=3DDIR C header files [PREFIX/include] --oldincludedir=3DDIR C header files for non-gcc [/usr/include] diff --git a/stubdom/configure b/stubdom/configure index da03da535a..f7604a37f7 100755 --- a/stubdom/configure +++ b/stubdom/configure @@ -661,7 +661,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -751,7 +750,6 @@ datadir=3D'${datarootdir}' sysconfdir=3D'${prefix}/etc' sharedstatedir=3D'${prefix}/com' localstatedir=3D'${prefix}/var' -runstatedir=3D'${localstatedir}/run' includedir=3D'${prefix}/include' oldincludedir=3D'/usr/include' docdir=3D'${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1004,15 +1002,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=3Dyes ;; =20 - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=3Drunstatedir ;; - -runstatedir=3D* | --runstatedir=3D* | --runstatedi=3D* | --runstated=3D= * \ - | --runstate=3D* | --runstat=3D* | --runsta=3D* | --runst=3D* | --runs= =3D* \ - | --run=3D* | --ru=3D* | --r=3D*) - runstatedir=3D$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=3Dsbindir ;; -sbindir=3D* | --sbindir=3D* | --sbindi=3D* | --sbind=3D* | --sbin=3D* \ @@ -1150,7 +1139,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=3D\$$ac_var # Remove trailing slashes. @@ -1303,7 +1292,6 @@ Fine tuning of the installation directories: --sysconfdir=3DDIR read-only single-machine data [PREFIX/etc] --sharedstatedir=3DDIR modifiable architecture-independent data [PREF= IX/com] --localstatedir=3DDIR modifiable single-machine data [PREFIX/var] - --runstatedir=3DDIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=3DDIR object code libraries [EPREFIX/lib] --includedir=3DDIR C header files [PREFIX/include] --oldincludedir=3DDIR C header files for non-gcc [/usr/include] diff --git a/tools/config.h.in b/tools/config.h.in index 5a5944ebe1..5abf6092de 100644 --- a/tools/config.h.in +++ b/tools/config.h.in @@ -123,6 +123,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS =20 +/* QMP proxy path */ +#undef STUBDOM_QMP_PROXY_PATH + /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE # define _DARWIN_USE_64_BIT_INODE 1 diff --git a/tools/configure b/tools/configure index 36596389b8..35036dc1db 100755 --- a/tools/configure +++ b/tools/configure @@ -772,7 +772,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -814,6 +813,7 @@ with_linux_backend_modules enable_qemu_traditional enable_rombios with_system_qemu +with_stubdom_qmp_proxy with_system_seabios with_system_ovmf enable_ipxe @@ -899,7 +899,6 @@ datadir=3D'${datarootdir}' sysconfdir=3D'${prefix}/etc' sharedstatedir=3D'${prefix}/com' localstatedir=3D'${prefix}/var' -runstatedir=3D'${localstatedir}/run' includedir=3D'${prefix}/include' oldincludedir=3D'/usr/include' docdir=3D'${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1152,15 +1151,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=3Dyes ;; =20 - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=3Drunstatedir ;; - -runstatedir=3D* | --runstatedir=3D* | --runstatedi=3D* | --runstated=3D= * \ - | --runstate=3D* | --runstat=3D* | --runsta=3D* | --runst=3D* | --runs= =3D* \ - | --run=3D* | --ru=3D* | --r=3D*) - runstatedir=3D$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=3Dsbindir ;; -sbindir=3D* | --sbindir=3D* | --sbindi=3D* | --sbind=3D* | --sbin=3D* \ @@ -1298,7 +1288,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=3D\$$ac_var # Remove trailing slashes. @@ -1451,7 +1441,6 @@ Fine tuning of the installation directories: --sysconfdir=3DDIR read-only single-machine data [PREFIX/etc] --sharedstatedir=3DDIR modifiable architecture-independent data [PREF= IX/com] --localstatedir=3DDIR modifiable single-machine data [PREFIX/var] - --runstatedir=3DDIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=3DDIR object code libraries [EPREFIX/lib] --includedir=3DDIR C header files [PREFIX/include] --oldincludedir=3DDIR C header files for non-gcc [/usr/include] @@ -1535,6 +1524,9 @@ Optional Packages: Use system supplied qemu PATH or qemu (taken from $PATH) as qemu-xen device model instead of build= ing and installing our own version + --stubdom-qmp-proxy[=3DPATH] + Use supplied binary PATH as a QMP proxy into + stubdomain --with-system-seabios[=3DPATH] Use system supplied seabios PATH instead of buil= ding and installing our own version @@ -3382,7 +3374,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) <<= 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 =3D=3D 721 && LARGE_OFF_T % 2147483647 =3D=3D 1) ? 1 : -1]; @@ -3428,7 +3420,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) <<= 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 =3D=3D 721 && LARGE_OFF_T % 2147483647 =3D=3D 1) ? 1 : -1]; @@ -3452,7 +3444,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.= $ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) <<= 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 =3D=3D 721 && LARGE_OFF_T % 2147483647 =3D=3D 1) ? 1 : -1]; @@ -3497,7 +3489,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) <<= 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 =3D=3D 721 && LARGE_OFF_T % 2147483647 =3D=3D 1) ? 1 : -1]; @@ -3521,7 +3513,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.= $ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) <<= 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 =3D=3D 721 && LARGE_OFF_T % 2147483647 =3D=3D 1) ? 1 : -1]; @@ -4548,6 +4540,24 @@ _ACEOF =20 =20 =20 +# Check whether --with-stubdom-qmp-proxy was given. +if test "${with_stubdom_qmp_proxy+set}" =3D set; then : + withval=3D$with_stubdom_qmp_proxy; + stubdom_qmp_proxy=3D"$withval" + +else + + stubdom_qmp_proxy=3D"$bindir/vchan-socket-proxy" + +fi + + +cat >>confdefs.h <<_ACEOF +#define STUBDOM_QMP_PROXY_PATH "$stubdom_qmp_proxy" +_ACEOF + + + # Check whether --with-system-seabios was given. if test "${with_system_seabios+set}" =3D set; then : withval=3D$with_system_seabios; diff --git a/tools/configure.ac b/tools/configure.ac index b6f8882be4..a9af0a21c6 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -194,6 +194,15 @@ AC_SUBST(qemu_xen) AC_SUBST(qemu_xen_path) AC_SUBST(qemu_xen_systemd) =20 +AC_ARG_WITH([stubdom-qmp-proxy], + AC_HELP_STRING([--stubdom-qmp-proxy@<:@=3DPATH@:>@], + [Use supplied binary PATH as a QMP proxy into stubdomain]),[ + stubdom_qmp_proxy=3D"$withval" +],[ + stubdom_qmp_proxy=3D"$bindir/vchan-socket-proxy" +]) +AC_DEFINE_UNQUOTED([STUBDOM_QMP_PROXY_PATH], ["$stubdom_qmp_proxy"], [QMP = proxy path]) + AC_ARG_WITH([system-seabios], AS_HELP_STRING([--with-system-seabios@<:@=3DPATH@:>@], [Use system supplied seabios PATH instead of building and installing diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 6829b4bdb5..6a26634ef9 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1200,7 +1200,11 @@ static int libxl__build_device_model_args_new(libxl_= _gc *gc, GCSPRINTF("%d", guest_domid), NULL); flexarray_append(dm_args, "-no-shutdown"); =20 - /* There is currently no way to access the QMP socket in the stubdom */ + /* + * QMP access to qemu running in stubdomain is done over vchan. The + * stubdomain init script adds the appropriate monitor options for + * vchan-socket-proxy. + */ if (!is_stubdom) { flexarray_append(dm_args, "-chardev"); if (state->dm_monitor_fd >=3D 0) { @@ -2205,6 +2209,23 @@ static void stubdom_pvqemu_unpaused(libxl__egc *egc, static void stubdom_xswait_cb(libxl__egc *egc, libxl__xswait_state *xswait, int rc, const char *p); =20 +static void spawn_qmp_proxy(libxl__egc *egc, + libxl__stub_dm_spawn_state *sdss); + +static void qmp_proxy_confirm(libxl__egc *egc, libxl__spawn_state *spawn, + const char *xsdata); + +static void qmp_proxy_startup_failed(libxl__egc *egc, + libxl__spawn_state *spawn, + int rc); + +static void qmp_proxy_detached(libxl__egc *egc, + libxl__spawn_state *spawn); + +static void qmp_proxy_spawn_outcome(libxl__egc *egc, + libxl__stub_dm_spawn_state *sdss, + int rc); + char *libxl__stub_dm_name(libxl__gc *gc, const char *guest_name) { return GCSPRINTF("%s-dm", guest_name); @@ -2486,24 +2507,150 @@ static void spawn_stub_launch_dm(libxl__egc *egc, goto out; } =20 + sdss->qmp_proxy_spawn.ao =3D ao; + if (libxl__stubdomain_is_linux(&guest_config->b_info)) { + spawn_qmp_proxy(egc, sdss); + } else { + qmp_proxy_spawn_outcome(egc, sdss, 0); + } + + return; + +out: + assert(ret); + qmp_proxy_spawn_outcome(egc, sdss, ret); +} + +static void spawn_qmp_proxy(libxl__egc *egc, + libxl__stub_dm_spawn_state *sdss) +{ + STATE_AO_GC(sdss->qmp_proxy_spawn.ao); + const uint32_t guest_domid =3D sdss->dm.guest_domid; + const uint32_t dm_domid =3D sdss->pvqemu.guest_domid; + const char *dom_path =3D libxl__xs_get_dompath(gc, dm_domid); + char **args; + int nr =3D 0; + int rc, logfile_w, null; + + if (access(STUBDOM_QMP_PROXY_PATH, X_OK) < 0) { + LOGED(ERROR, guest_domid, "qmp proxy %s is not executable", STUBDO= M_QMP_PROXY_PATH); + rc =3D ERROR_FAIL; + goto out; + } + + sdss->qmp_proxy_spawn.what =3D GCSPRINTF("domain %d device model qmp p= roxy", guest_domid); + sdss->qmp_proxy_spawn.pidpath =3D GCSPRINTF("%s/image/qmp-proxy-pid", = dom_path); + sdss->qmp_proxy_spawn.xspath =3D DEVICE_MODEL_XS_PATH(gc, LIBXL_TOOLST= ACK_DOMID, + dm_domid, "/qmp-pr= oxy-state"); + sdss->qmp_proxy_spawn.timeout_ms =3D LIBXL_DEVICE_MODEL_START_TIMEOUT = * 1000; + sdss->qmp_proxy_spawn.midproc_cb =3D libxl__spawn_record_pid; + sdss->qmp_proxy_spawn.confirm_cb =3D qmp_proxy_confirm; + sdss->qmp_proxy_spawn.failure_cb =3D qmp_proxy_startup_failed; + sdss->qmp_proxy_spawn.detached_cb =3D qmp_proxy_detached; + + const int arraysize =3D 6; + GCNEW_ARRAY(args, arraysize); + args[nr++] =3D STUBDOM_QMP_PROXY_PATH; + args[nr++] =3D GCSPRINTF("--state-path=3D%s", sdss->qmp_proxy_spawn.xs= path); + args[nr++] =3D GCSPRINTF("%u", dm_domid); + args[nr++] =3D GCSPRINTF("%s/device-model/%u/qmp-vchan", dom_path, gue= st_domid); + args[nr++] =3D (char*)libxl__qemu_qmp_path(gc, guest_domid); + args[nr++] =3D NULL; + assert(nr =3D=3D arraysize); + + logfile_w =3D libxl__create_qemu_logfile(gc, GCSPRINTF("qmp-proxy-%s", + sdss->dm_config.c= _info.name)); + if (logfile_w < 0) { + rc =3D logfile_w; + goto out; + } + null =3D open("/dev/null", O_RDWR); + if (null < 0) { + LOGED(ERROR, guest_domid, "unable to open /dev/null"); + rc =3D ERROR_FAIL; + goto out_close; + } + + rc =3D libxl__spawn_spawn(egc, &sdss->qmp_proxy_spawn); + if (rc < 0) + goto out_close; + if (!rc) { /* inner child */ + setsid(); + libxl__exec(gc, null, null, logfile_w, STUBDOM_QMP_PROXY_PATH, arg= s, NULL); + /* unreachable */ + } + + rc =3D 0; + +out_close: + if (logfile_w >=3D 0) + close(logfile_w); + if (null >=3D 0) + close(null); +out: + if (rc) + qmp_proxy_spawn_outcome(egc, sdss, rc); +} + +static void qmp_proxy_confirm(libxl__egc *egc, libxl__spawn_state *spawn, + const char *xsdata) +{ + STATE_AO_GC(spawn->ao); + + if (!xsdata) + return; + + if (strcmp(xsdata, "running")) + return; + + libxl__spawn_initiate_detach(gc, spawn); +} + +static void qmp_proxy_startup_failed(libxl__egc *egc, + libxl__spawn_state *spawn, + int rc) +{ + libxl__stub_dm_spawn_state *sdss =3D CONTAINER_OF(spawn, *sdss, qmp_pr= oxy_spawn); + qmp_proxy_spawn_outcome(egc, sdss, rc); +} + +static void qmp_proxy_detached(libxl__egc *egc, + libxl__spawn_state *spawn) +{ + libxl__stub_dm_spawn_state *sdss =3D CONTAINER_OF(spawn, *sdss, qmp_pr= oxy_spawn); + qmp_proxy_spawn_outcome(egc, sdss, 0); +} + +static void qmp_proxy_spawn_outcome(libxl__egc *egc, + libxl__stub_dm_spawn_state *sdss, + int rc) +{ + STATE_AO_GC(sdss->qmp_proxy_spawn.ao); + int need_pvqemu =3D libxl__need_xenpv_qemu(gc, &sdss->dm_config); + + if (rc) goto out; + + if (need_pvqemu < 0) { + rc =3D need_pvqemu; + goto out; + } + sdss->pvqemu.spawn.ao =3D ao; - sdss->pvqemu.guest_domid =3D dm_domid; sdss->pvqemu.guest_config =3D &sdss->dm_config; sdss->pvqemu.build_state =3D &sdss->dm_state; sdss->pvqemu.callback =3D spawn_stubdom_pvqemu_cb; - - if (!need_qemu) { + if (need_pvqemu) { + libxl__spawn_local_dm(egc, &sdss->pvqemu); + } else { /* If dom0 qemu not needed, do not launch it */ spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu, 0); - } else { - libxl__spawn_local_dm(egc, &sdss->pvqemu); } =20 return; =20 out: - assert(ret); - spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu, ret); + assert(rc); + spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu, rc); } =20 static void spawn_stubdom_pvqemu_cb(libxl__egc *egc, diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index fef2cd4e13..c08af308fa 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1260,10 +1260,20 @@ static void dm_destroy_cb(libxl__egc *egc, libxl__destroy_domid_state *dis =3D CONTAINER_OF(ddms, *dis, ddms); STATE_AO_GC(dis->ao); uint32_t domid =3D dis->domid; + uint32_t target_domid; =20 if (rc < 0) LOGD(ERROR, domid, "libxl__destroy_device_model failed"); =20 + if (libxl_is_stubdom(CTX, domid, &target_domid) && + libxl__stubdomain_is_linux_running(gc, target_domid)) { + char *path =3D GCSPRINTF("/local/domain/%d/image/qmp-proxy-pid", d= omid); + + libxl__kill_xs_path(gc, path, "QMP Proxy"); + /* qmp-proxy for stubdom registers target_domid's QMP sockets. */ + libxl__qmp_cleanup(gc, target_domid); + } + dis->drs.ao =3D ao; dis->drs.domid =3D domid; dis->drs.callback =3D devices_destroy_cb; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index c939557b2e..41b51b07cd 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -4166,6 +4166,7 @@ typedef struct { libxl__destroy_domid_state dis; libxl__multidev multidev; libxl__xswait_state xswait; + libxl__spawn_state qmp_proxy_spawn; } libxl__stub_dm_spawn_state; =20 _hidden void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_st= ate*); --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853446; cv=none; d=zohomail.com; s=zohoarc; b=VgAWs0lIXLg3shTLOtN8ZeTjn4zBAqbvOo1DV3ujNhVS4NzeX3icko2j7GsDNtqwB62meNuHGTjfIZW+YbGQrVEDdQtQP+ivPOD4cxRapd+dH6QomlgzzuK30pc9+Qd+xYtf0JMqxuYwlYNLZ3WchgNCWapyDYPDVn09eAxWkf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853446; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zYxVyaXUbBwkO6YpZAMxyMF5n/sB6urbfp9DtPJAZLw=; b=OJvpcT5/6PLSBTcXJQ4pCUK1HEcZkZKWBBlWEh3StwrFYPiEkMSqtHyl9v3xW1gnjmm9MMXQpAvZ+1VLNh7lm+Vl9Gl0JGuvRRLsKAQqtjQeD4C6olj7yF0GkQPb39AXisBZCCSYyWNmJLXT0c+mWQCGuh6iIRGpAXdNCniIa40= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853446369401.1625046710069; Mon, 18 May 2020 18:57:26 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarV9-0000qS-MI; Tue, 19 May 2020 01:57:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarV8-0000pU-NJ for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:57:02 +0000 Received: from mail-qk1-x742.google.com (unknown [2607:f8b0:4864:20::742]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id edfca300-9973-11ea-b9cf-bc764e2007e4; Tue, 19 May 2020 01:56:18 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id f189so12871719qkd.5 for ; Mon, 18 May 2020 18:56:18 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:16 -0700 (PDT) X-Inumbo-ID: edfca300-9973-11ea-b9cf-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zYxVyaXUbBwkO6YpZAMxyMF5n/sB6urbfp9DtPJAZLw=; b=IEQEPkp6jaiAgX30wKH3RXdIuyHNp1qM8Fw1z/Z62607XhkY4lacJtOHt+hqwYcIWf aGrHGEik84VfUwSLpYvKSyVxG5+BgRGuXr6v3TxXyLG9ZHNJ1xEEi7INszUrd9l7G1ey Cs8p2M+35n0Bz1b1NldY6x3FKEwMy12GghFmAvPC84/Q3kFGhzMXiqb01UG75B5iqUt/ p0mtcugDY/gGwmtXsz8tjq63gLqfg8hJFiRD5zlLSeBAkL4BwOGnf95oiOcQraz3GdRb 7AU3g7qmzk6TywvzyhjJesjVIqp380CH/npcDCgj+2uV/xkCyznrpxWr5l9mnEnr1VMn igwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zYxVyaXUbBwkO6YpZAMxyMF5n/sB6urbfp9DtPJAZLw=; b=LwzaPSGcBjp9PChfNPfYhmRzuv7gSUT+e2uF2LBMupjbFp16pG4Jze29FWgdabRyPw T0Yrmg1BqIltqFTHcGBhnUZmF+c7CIGuK6/QgHi3aDQmygZaz1SHeLpZ/sLj2n53R2Yb 7c2sFapL9qX0Wq6RlOEcpIij/HCLD0H7zCAyrRUuGxF9coTSjIgHZKQL5WEFq29cGOks Su/BbpNA/c/opyzuRafqY9pXmS9OXfqS4G1xaTr7fkXNHTrWh5PbT7wB5/eFJkAU/UHI tqrHywlKQ8oA5AAhWQtF9fMPv1aRBuViT3i3F/5E3O7tToYvk/hYI9bKiFTVoC7526S4 pQ4Q== X-Gm-Message-State: AOAM530AmB2Gjva3aMMkf5b1HoshhIMy0nUdWjU73Lk3bgV3Bsosfh46 s//cwqOKqJRPYDzoHCxA1JNeXEHA X-Google-Smtp-Source: ABdhPJwzwY9WPZYTCdyanB+pJDmCSgNFO0oQxnmRTaaX0i7nC3iWT7eVbJSXqPrdH6UsWw3+ZdfUEA== X-Received: by 2002:a37:59c7:: with SMTP id n190mr8225930qkb.471.1589853377492; Mon, 18 May 2020 18:56:17 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 15/19] libxl: require qemu in dom0 for multiple stubdomain consoles Date: Mon, 18 May 2020 21:54:59 -0400 Message-Id: <20200519015503.115236-16-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Jason Andryuk , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Anthony PERARD , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Device model stubdomains (both Mini-OS + qemu-trad and linux + qemu-xen) are always started with at least 3 consoles: log, save, and restore. Until xenconsoled learns how to handle multiple consoles, this is needed for save/restore support. For Mini-OS stubdoms, this is a bug. In practice, it works in most cases because there is something else that triggers qemu in dom0 too: vfb/vkb added if vnc/sdl/spice is enabled. Additionally, Linux-based stubdomain waits for all the backends to initialize during boot. Lack of some console backends results in stubdomain startup timeout. This is a temporary patch until xenconsoled will be improved. Signed-off-by: Marek Marczykowski-G=C3=B3recki [Updated commit message with Marek's explanation from mailing list.] Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v6 - Update commit message Changes in v7 - Add Acked-by: Ian Jackson --- tools/libxl/libxl_dm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 6a26634ef9..8801e9364e 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2494,7 +2494,11 @@ static void spawn_stub_launch_dm(libxl__egc *egc, } } =20 - need_qemu =3D libxl__need_xenpv_qemu(gc, dm_config); + /* + * Until xenconsoled learns how to handle multiple consoles, require q= emu + * in dom0 to serve consoles for a stubdomain - it require at least 3 = of them. + */ + need_qemu =3D 1 || libxl__need_xenpv_qemu(gc, &sdss->dm_config); =20 for (i =3D 0; i < num_console; i++) { libxl__device device; @@ -2626,7 +2630,11 @@ static void qmp_proxy_spawn_outcome(libxl__egc *egc, int rc) { STATE_AO_GC(sdss->qmp_proxy_spawn.ao); - int need_pvqemu =3D libxl__need_xenpv_qemu(gc, &sdss->dm_config); + /* + * Until xenconsoled learns how to handle multiple consoles, require q= emu + * in dom0 to serve consoles for a stubdomain - it require at least 3 = of them. + */ + int need_pvqemu =3D 1 || libxl__need_xenpv_qemu(gc, &sdss->dm_config); =20 if (rc) goto out; =20 --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853451; cv=none; d=zohomail.com; s=zohoarc; b=cVEd+BBGpCGxkLtUpCzV9JVSp/MNXBWz6pOJF+bq/ca+JK8hACcPilb0idiZ9dJzl8bfo4bFkm2YqpVv4GLJQS6F0ipvL6oF1C225eM/EGFZt/IDVAB3zUhzi+dIJ4fkZ4dODVGGwudxfJhbXFEiaY8e0bfw5oByYy+qf2VpTuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853451; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h7aIlXvOP1lBOHwN5e2pe14rJQeMR42hM5D+KnY+oRg=; b=GolmL0YrQJ92zCtJYPU9OzjaVvFoRHDwTaEHWaKWuKwXxcy14nxT8iP5MYH8XEFGkUPPIdwbZr4lV7BwYrSSeRljK0K5ffQmzWw7UWf9ir8p/+H/I8S/pk7gW7kKhj/fJ3kA+AwYJI76+Y/oeAO5nc9C7VF0yE+iI6B0HQplP8w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853451933610.4691062360614; Mon, 18 May 2020 18:57:31 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarVF-0000vx-3z; Tue, 19 May 2020 01:57:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarVD-0000uM-Nv for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:57:07 +0000 Received: from mail-qv1-xf41.google.com (unknown [2607:f8b0:4864:20::f41]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f1360638-9973-11ea-b9cf-bc764e2007e4; Tue, 19 May 2020 01:56:23 +0000 (UTC) Received: by mail-qv1-xf41.google.com with SMTP id dh1so1897811qvb.13 for ; Mon, 18 May 2020 18:56:23 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:22 -0700 (PDT) X-Inumbo-ID: f1360638-9973-11ea-b9cf-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h7aIlXvOP1lBOHwN5e2pe14rJQeMR42hM5D+KnY+oRg=; b=EMoFpo3VZpwrzTvutQCIzi+e5oMDXAf/1WVqqKsGMdaN+B6PPKLXvSJQ30kPoOncup 8IVklOgU6XOROC1iMAvMXRX2ajS52STcAAiEzjM1BzVtaIUeH4Erfni7CtAaReIdtraP Ri1JABHCyznsDLRuMxJEhWtgWfX1PI2ICSpFxMqJ3y+t15SWRZYt77vM4lXN8ohwgpCE zhDaMH2yzTkRCSOCJcsF7chfFhpHDx5mCin4dz6xIoR9P95AJiQNGR2LFu0hstby1V17 dvuQ7fO8+R9cWhsNHBQ4yDM/MNla0HpVj06PUlCGkDW6VfZ/vksDaZMGAYBcqsZaPJRJ amDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h7aIlXvOP1lBOHwN5e2pe14rJQeMR42hM5D+KnY+oRg=; b=AneQ7W4QTsIUeRODp00Wu/MsyXVr7MXue82ud9jB73UYAFe/44Wp+qhBPFZ/tI78vn tA4udW+xceRbrbxwDDeXv2RGinm5/Rq/+CgUFTzheU2/jNJai+d+GWH0CiJNghPCmOoD BPK10hIT0f8lLD49FeJsdxy516fWYUR2jTCoWMIPVd8Q1G0ZdIf9nKOmUYcTA6JPb8Nt PQQsF4vrzMGZY8smFIpCCig8RL9kIjLXisEZc5ZgcBWCuEcsUD11PFXmqEoIqTGQP6/6 kK0SE98WvNkq3qNqns3lNvSx/HOck2wZI9lqvlxg+ol8SZv/ueZTYzx+lHbzFF8wByFV Taww== X-Gm-Message-State: AOAM530/Zmh1P//++w2EP3OXGrQpLa5KLY2dwfkQcawvea+2MBUVyiiH GprfDnYOSke6A7R4nJl5EkKYMSVO X-Google-Smtp-Source: ABdhPJy3v6xUElp1+dZ+UyZkFnEv8EEcgqtN7mGKsvOX6ZOSF0gdR6ZsfCJ4wXY6Uqs9zNd5eeYzQg== X-Received: by 2002:a05:6214:42f:: with SMTP id a15mr18469050qvy.170.1589853383034; Mon, 18 May 2020 18:56:23 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 16/19] libxl: ignore emulated IDE disks beyond the first 4 Date: Mon, 18 May 2020 21:55:00 -0400 Message-Id: <20200519015503.115236-17-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Jason Andryuk , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Anthony PERARD , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Qemu supports only 4 emulated IDE disks, when given more (or with higher indexes), it will fail to start. Since the disks can still be accessible using PV interface, just ignore emulated path and log a warning, instead of rejecting the configuration altogether. Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Jason Andryuk Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v6: - Add Acked-by: Ian Jackson --- tools/libxl/libxl_dm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 8801e9364e..86694f669d 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1894,6 +1894,13 @@ static int libxl__build_device_model_args_new(libxl_= _gc *gc, } =20 if (disks[i].is_cdrom) { + if (disk > 4) { + LOGD(WARN, guest_domid, "Emulated CDROM can be only on= e of the first 4 disks.\n" + "Disk %s will be available via PV drivers but not= as an " + "emulated disk.", + disks[i].vdev); + continue; + } drive =3D libxl__sprintf(gc, "if=3Dide,index=3D%d,readonly=3Don,media=3Dcdrom,= id=3Dide-%i", disk, dev_number); @@ -1971,6 +1978,10 @@ static int libxl__build_device_model_args_new(libxl_= _gc *gc, &disks[i], colo_mode); } else { + LOGD(WARN, guest_domid, "Only 4 emulated IDE disks are= supported.\n" + "Disk %s will be available via PV drivers but not= as an " + "emulated disk.", + disks[i].vdev); continue; /* Do not emulate this disk */ } =20 --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853457; cv=none; d=zohomail.com; s=zohoarc; b=jMQlwNnoDwogY/NacBnOOTR5PBZTi558/FP9rqtvsALifdwyGhvmmBYgzkt5AiJVTD8s7PLQzmZOtEI8O3lDYlYj4EfcBq9xYL5Rq0hLX6lcd9hTeEDDuCqv/6W+vkvBiJdyt67kbYEU3iTMaitTZ/8w1W8gyghvpTz0cXl5dlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853457; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IYMgysvcDxJ2qC+BMVljgkXJOptYz7V/ebvMGJu6l2I=; b=FIs/D2Hq6G91rp/K7M0ZtEoPovHMV2+KQLZtyj//z2VpCx4+E1tha/B5//tRkutpbY3rxhMZLgU0s/WfUTTSRGtZTljjXnOhIvDSau9nUdPm/TBoX4voGQAGOW41RPs8+RGe/tGUh/z8QdsF3IdBCSqakKtg6rXRwdxWVvf2HKI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853457030829.4558254820864; Mon, 18 May 2020 18:57:37 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarVK-00011a-FJ; Tue, 19 May 2020 01:57:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarVI-0000zO-Ng for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:57:12 +0000 Received: from mail-qv1-xf44.google.com (unknown [2607:f8b0:4864:20::f44]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f23c3746-9973-11ea-b9cf-bc764e2007e4; Tue, 19 May 2020 01:56:25 +0000 (UTC) Received: by mail-qv1-xf44.google.com with SMTP id g20so5764037qvb.9 for ; Mon, 18 May 2020 18:56:25 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:24 -0700 (PDT) X-Inumbo-ID: f23c3746-9973-11ea-b9cf-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IYMgysvcDxJ2qC+BMVljgkXJOptYz7V/ebvMGJu6l2I=; b=iSZ+2fPcl6pHnJEzYSwp6UecgywSI0Do0bUYZEoGlESIz/C2NFxfo+kao2piWSIJ1R 2ss3oW3uGXdFjEgWoqiyeFRCxfe0TCV3jEtnTR4MnW5ZNw6REOc/hUprd3UmDu7svhov xcpESH85t4mv/RN9Db8AhFZMUmQzZbw6gNPAL6lakkYV8iiSN18ykFuCGo35tg0zjgM9 mScKM/4KLC7jS3mJugI7VN3k5+fNGiV6NpM6Mq6uUuZEPwYxsqY1N79n2Kt852amqMFY bUSaaJobFK0VObOJg+EL3mSMBxsYYCLS6bOJzTXqWkY4BLnRWJEa9cjAPT5v++HSAGkA ufAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IYMgysvcDxJ2qC+BMVljgkXJOptYz7V/ebvMGJu6l2I=; b=AoN7yDf64PgWvuwONrfeRosCDcKdlo8/8nYCB54Auo1bTJKBo3ieJKmGKAEnMzSM6R ViBMR2yvkCu9L65P5vFXHDwttGtT7BXr1bk7/oPdV54w14IyMzp1WqSTNUuYCzMQ0or8 9sf8WEU9eKzkMFDZd6nuT3OulqDTTsQrY6O7tuu8IEdbieLyhiFHt5iNm3qRR45RZP85 lVB73jLCD6y1AqiCiz32RLu40TkGDvkViq0J3tXgnvYnNwz3Prkz9C4H8ufFXV8YUys0 DeEVp6A9acH1eU8rDDc2wt3S4w71TwOTMgbcHQ/Gap3v3QUtL4tAK6alAV8D4a/v1iys rBfg== X-Gm-Message-State: AOAM532WcEF7AxVTSNIRGhqP8rHhwezFqcBOy4ze5XgOor1rwZCfAFRo GNjSTzWrV9qnybCHeR1YwG++u8rD X-Google-Smtp-Source: ABdhPJx+JJQZcXHO93LyrGJBq5x/P47XOfWXMJ7IPmronv27b21xMNl7q4ygzJNCos1CMGew2EZ6pg== X-Received: by 2002:ad4:40ca:: with SMTP id x10mr19055315qvp.220.1589853384762; Mon, 18 May 2020 18:56:24 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 17/19] libxl: consider also qemu in stubdomain in libxl__dm_active check Date: Mon, 18 May 2020 21:55:01 -0400 Message-Id: <20200519015503.115236-18-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Jason Andryuk , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Anthony PERARD , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marek Marczykowski-G=C3=B3recki Since qemu-xen can now run in stubdomain too, handle this case when checking it's state too. Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Jason Andryuk Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v6: - Add Acked-by: Ian Jackson --- tools/libxl/libxl_dm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 86694f669d..454a2815ed 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -3734,12 +3734,18 @@ out: =20 int libxl__dm_active(libxl__gc *gc, uint32_t domid) { - char *pid, *path; + char *pid, *dm_domid, *path; =20 path =3D GCSPRINTF("/local/domain/%d/image/device-model-pid", domid); pid =3D libxl__xs_read(gc, XBT_NULL, path); =20 - return pid !=3D NULL; + if (pid) + return true; + + path =3D GCSPRINTF("/local/domain/%d/image/device-model-domid", domid); + dm_domid =3D libxl__xs_read(gc, XBT_NULL, path); + + return dm_domid !=3D NULL; } =20 int libxl__dm_check_start(libxl__gc *gc, libxl_domain_config *d_config, --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853461; cv=none; d=zohomail.com; s=zohoarc; b=OyVuOBC3SK3P8FXtSZzMHGiBEL+DjrHeUNnZIDjfjk6UUjrI8FfYPG7ftjzwX0ZMdgKNFAgX08zg79fkBoK+/xhw6VrkbhWk6gCAWPF/MwqdpjnidrWHlN9wIJMiH7SmSqxHEQtzflNPQ1pAUSZDvbPxTsFj7dZDSRi7Mb3dl8w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853461; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aXBQgi2sAye4H55aK3umMyFvWsC+VqqA4xSnBHzfcsA=; b=SRzYTb4itGGrVK6q5ltPtt4LAM+Qq5h/ZiOJwHp3NBbzicty6lBnX1lKWswqV274yoNNDpPZPsElWojzkEtsNUajb7W/uvvsrnYXyaPSxq+kqv89JCjtkMbhdkUUGnqKJ97Vskws8Rx9EzBEvPiuP+GbpCdlf313eTLYdiCR1lI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853461409380.84284655270585; Mon, 18 May 2020 18:57:41 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarVO-00015l-RS; Tue, 19 May 2020 01:57:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarVN-00014l-NM for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:57:17 +0000 Received: from mail-qt1-x842.google.com (unknown [2607:f8b0:4864:20::842]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f36e41b8-9973-11ea-b07b-bc764e2007e4; Tue, 19 May 2020 01:56:27 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id o19so9895427qtr.10 for ; Mon, 18 May 2020 18:56:27 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:25 -0700 (PDT) X-Inumbo-ID: f36e41b8-9973-11ea-b07b-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aXBQgi2sAye4H55aK3umMyFvWsC+VqqA4xSnBHzfcsA=; b=mU+6BsnXFny2vtjKJ7i2MqzmjsByZT7LuGqKAmoJxuA8CfzxfN68x19jSieBJ9mFvy sH7P/lMzGGLi7uGGAx+jhC0nEko/+P2bZWYr7+SxqPqEi6XSQ2CgzAaIhOJYOcgHpvKG Prfgt9bJ6k1IHH8YuyPXhKNvYX+GdoNAZvn3lkPm/qjZ8uHGFi0Us8OXTMLJcXUSsSTg owlWvUDk/l2/FHzsjFVj4UkeZqINJ5mge2RFk6PV304ssF6OyVmKqMIDRsDGuQPo5BXv CVA1oXOqw8ZmaXYXIPnoak4/to9zpCRJS6R+OOyfIxYkNLfdCoIi2XWTwZKkWCMwCEaP 9Fcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aXBQgi2sAye4H55aK3umMyFvWsC+VqqA4xSnBHzfcsA=; b=qHYMRcivoubHaHddF5HOAs+FFjb0hOLNwknqFP+VnMO/18181IUN28bKZHHm0CmVPj +zMKNb32oh91eEw+3BImrpCFhtFV0mUvKQm2w+hZRiXg96SLgjOY1qY7VZthrCP9XFLT z3a8hXNgOoy3pH0BCdrDFy5Ayh6gi2zcs+45hzIvLJwMABVzpHPh264lBBUHohQLtwa3 nR7eMAd1hOFbPZK4+IRiLNg9yFYv6poAyhkhNur0rkLE7kHL6XltsxBrPpbNKL0EW/jy vtxYj4pj+m34k6HTcZ7Z39rtPVMA1qXUhUmRkzmppmFaI7PYkUBLzGJRD2Tsa4FauZem I2Eg== X-Gm-Message-State: AOAM533Uq1ciD8pMPsQHOMd3dS44KIpnkmfUCyZmRiPe8M9eWzKP7jy1 rlDGLmR20mn/k2TAgLr66EgBB0cK X-Google-Smtp-Source: ABdhPJyOiC2OceB9Rb7cENPNDP6xt/sf5xjwv66y7Sna7Gqonzk3hgNejlfWlv7lb7Of+q2Ktn2LQw== X-Received: by 2002:ac8:3693:: with SMTP id a19mr12844368qtc.226.1589853386733; Mon, 18 May 2020 18:56:26 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 18/19] docs: Add device-model-domid to xenstore-paths Date: Mon, 18 May 2020 21:55:02 -0400 Message-Id: <20200519015503.115236-19-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Jason Andryuk , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Document device-model-domid for when using a device model stubdomain. Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v6: - Add Acked-by: Ian Jackson --- docs/misc/xenstore-paths.pandoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/misc/xenstore-paths.pandoc b/docs/misc/xenstore-paths.pan= doc index a152f5ea68..766e8008dc 100644 --- a/docs/misc/xenstore-paths.pandoc +++ b/docs/misc/xenstore-paths.pandoc @@ -148,6 +148,11 @@ The domain's own ID. The process ID of the device model associated with this domain, if it has one. =20 +#### ~/image/device-model-domid =3D INTEGER [INTERNAL] + +The domain ID of the device model stubdomain associated with this domain, +if it has one. + #### ~/cpu/[0-9]+/availability =3D ("online"|"offline") [PV] =20 One node for each virtual CPU up to the guest's configured --=20 2.25.1 From nobody Sat Apr 20 00:04:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589853465; cv=none; d=zohomail.com; s=zohoarc; b=Sog3LvFYKZL0v/wM18hbe2SE4tEyVw18XDPXZY3qMklRzUDm9gKXIV3r4rQLlwshjKPdaOlu/OwnKM8RciVqhVWqDcGQYuPbG5B4Q0qFm7EZBkArXV5Jmj6Jx3kffWE+/ewJ3wAihOyvBYi1oOU92EsPc/dxN/uj2/gjRfK5Yv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589853465; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9lx2s1mvPB2z7P0TCofZ4ZdaYHQdnvDFnijuTkR+OyI=; b=IS8vnJF1OuyMPcP0iwfK3CaFCvzMrOaWJNq7O9ud79YfW0vYDi2p4k2H7SnniVGpuePcg40qRLSQMF+fChIab7J5MA2zXaRahHw5R9a1EEzAIcnw5ZSPPjOo2koMk1j52XzL4t73qPkHuik7KeUnSkD32lkSapArqzp7tDFmbsU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589853465484671.2510630188842; Mon, 18 May 2020 18:57:45 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarVU-0001Ak-40; Tue, 19 May 2020 01:57:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jarVS-00019O-NQ for xen-devel@lists.xenproject.org; Tue, 19 May 2020 01:57:22 +0000 Received: from mail-qt1-x842.google.com (unknown [2607:f8b0:4864:20::842]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f47caa90-9973-11ea-9887-bc764e2007e4; Tue, 19 May 2020 01:56:29 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id x12so9906678qts.9 for ; Mon, 18 May 2020 18:56:29 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:e463:db9c:c6eb:4544]) by smtp.gmail.com with ESMTPSA id q2sm9731898qkn.116.2020.05.18.18.56.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 18:56:27 -0700 (PDT) X-Inumbo-ID: f47caa90-9973-11ea-9887-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9lx2s1mvPB2z7P0TCofZ4ZdaYHQdnvDFnijuTkR+OyI=; b=DQA/lDYikmIzpyMpAWL2Ah5GnWBzNAHqJQmCFJLRMgO19L1i6DmfI8Sfarert7aqF+ YJp+hF5fIZ6nCcfx9JwziCSXHP837ryCwPcafLU9RNqq5Cu0S64EOPWg6qd3EhV//SoD qxvB3d6fF/rb81+GioysD7qWJ3/nHLu5lO1WIkx+Ijyqpb0Bwr+T5541GMwMsdO7StDr dwbKcwkKg7nkoSNXRM6EkQ8Qt8CUU1aNjiXhaPAPZcBsRRxnLvLDR51h7TpvZtBfYVSd GyDCBb11ezV4FBFARzm2aM4gvyk+6XTqx1LqxUBO1ri9b6FB1ediTL0cemyaxDy9EX+/ q/ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9lx2s1mvPB2z7P0TCofZ4ZdaYHQdnvDFnijuTkR+OyI=; b=OEit5RLGrWOiD74QYWZuObZb0rHnaXsASa9sRK4kgOauaAUv/rKZ5kLX1RkEDVx2j0 AIDz0zQ6wYk6u5hPoRgNNyP5ndDjiNDYVsyOT/0qDsNqWFb1TSCS1b1IDN+fyYoVQ9xv lLquNrBfYzzxjh24YL0IAX94flbH7qA9ttG/iiZ1+vLrNzt/RBv0No9QHjgy1F6SK7x8 XPwLvepEbdPq3uKpYvqR39NR0EuOLd1MNyve7BEi2YKupUi+bcj3iFt6s/0UY2g6pMgZ hhO4BBg1fUyhaM7AbFeJy/9xMIUrbBna6zrJ+sUy3pnTto4NVRrkBIHDog4A9JV72WkL LDzw== X-Gm-Message-State: AOAM532x/B5+h3C9kpxFlJvVjwpRey+ZJOumgZRKJM4RI0tMTq55zMeS jbkNRV2Fx+3/aeC3+3wUEmpgqY9U X-Google-Smtp-Source: ABdhPJw5yZkFl9IpXV431nEJj85p8N0Z6g2agmpa0BQy0bXY2sJpEBqPeZOKzx+Y+vo9oz0spg//vw== X-Received: by 2002:ac8:6d3a:: with SMTP id r26mr19493770qtu.65.1589853388518; Mon, 18 May 2020 18:56:28 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Subject: [PATCH v7 19/19] libxl: Check stubdomain kernel & ramdisk presence Date: Mon, 18 May 2020 21:55:03 -0400 Message-Id: <20200519015503.115236-20-jandryuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200519015503.115236-1-jandryuk@gmail.com> References: <20200519015503.115236-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , Ian Jackson , Wei Liu , Jason Andryuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Just out of context is the following comment for libxl__domain_make: /* fixme: this function can leak the stubdom if it fails */ When the stubdomain kernel or ramdisk is not present, the domid and stubdomain name will indeed be leaked. Avoid the leak by checking the file presence and erroring out when absent. It doesn't fix all cases, but it avoids a big one when using a linux device model stubdomain. Signed-off-by: Jason Andryuk Acked-by: Ian Jackson --- Changes in v6: - Add Acked-by: Ian Jackson --- tools/libxl/libxl_dm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 454a2815ed..f2dc5696b9 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2327,6 +2327,22 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__st= ub_dm_spawn_state *sdss) dm_config->num_vkbs =3D 1; } =20 + if (guest_config->b_info.stubdomain_kernel && + access(guest_config->b_info.stubdomain_kernel, R_OK) !=3D 0) { + LOGED(ERROR, guest_domid, "could not access stubdomain kernel %s", + guest_config->b_info.stubdomain_kernel); + ret =3D ERROR_INVAL; + goto out; + } + + if (guest_config->b_info.stubdomain_ramdisk && + access(guest_config->b_info.stubdomain_ramdisk, R_OK) !=3D 0) { + LOGED(ERROR, guest_domid, "could not access stubdomain ramdisk %s", + guest_config->b_info.stubdomain_ramdisk); + ret =3D ERROR_INVAL; + goto out; + } + stubdom_state->pv_kernel.path =3D guest_config->b_info.stubdomain_kern= el; stubdom_state->pv_ramdisk.path =3D guest_config->b_info.stubdomain_ram= disk; =20 --=20 2.25.1