From nobody Mon Feb 9 11:30:43 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1568914923; cv=none; d=zoho.com; s=zohoarc; b=UBMEUv8EFfarVTR5T/rWaJki/p+oBBq/GtLNpKCopAAU+gTXN2cA58TG5an2zRdSeYfpMu704YtlNb5A+0Yr3r3o2h0hFbmNXNQGNAfiuEV70qQZi9tjkIeBDyr1P3RImgc9dHZuRX+rxBBkQLgiTKmvF6578aUDBDDg1OERl2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568914923; 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:ARC-Authentication-Results; bh=DIXV3ajVFEAuYb8SBtqaTrp3yQlyVVtsQOmStWBYnXk=; b=dbYuZTKfMnNScAAfrB+CLB+D6JskGQDRkp6MgqWUdDkJRqhQowN82IdhSOi/JA7LuXssq6e2jfeircI6jkv6PZ87mzYd/rgrvrbMl1xAQU+M6rsLOaoMsAgevpv6dE7gxWJXtM70A6xkw7vhTftNS/f3GFJWtVc1nahVij/tyag= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1568914923210143.0210564259429; Thu, 19 Sep 2019 10:42:03 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iB0Ql-0004gD-Eu; Thu, 19 Sep 2019 17:41:23 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iB0Qj-0004e6-Jr for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 17:41:21 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b04a897e-db04-11e9-966e-12813bfff9fa; Thu, 19 Sep 2019 17:41:20 +0000 (UTC) X-Inumbo-ID: b04a897e-db04-11e9-966e-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568914879; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=42g1nRsubz8/EWiCmW1IVEW9Gu3YO6Yy4ytl2VdE9Jw=; b=PpxjO1ugFcnIAfUW7kx0JEmZMyqcEK1o6p9VZYErcEim9lC1AYL41JXt vnii090ttD0yETw+7D9j4m9nzZXxS2/pnUXOEyxk5wF8EEblL+BL8SYEB p1cN/cifrAOOzuMWMC4EM/hYlawFKmDbPVSp/H7W0pzUPjovEH107tLlm A=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: kgm5NJrYKv9LNZjCc54brSfTpiEyTIjPIsRy7l4mhpOAOKVWjZaSDbBqpC7k4+tLkOsrhSoqfb wluhKQcY/1lfXZgoPOIIog3F3WAjJSzMCfMFZZFHL0tKIgEzaYdAyhWgyO1w1/6xEROmf23lde YUBt5rk+oUCY3Jtj/3GhOt8jVcaJPR7WxYTUbfzbSumvqeZ+/Cu6rqsKgu0M8u5gTpxBDgN1pp Al0yOhXAqEW5uO0C1oRzuRQc4x0y0jNfbaAHVYdZ4QIsf05IBvLBKusOM6WaVEo38rl19VBxic MAE= X-SBRS: 2.7 X-MesageID: 6125295 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,524,1559534400"; d="scan'208";a="6125295" From: Anthony PERARD To: Date: Thu, 19 Sep 2019 18:16:55 +0100 Message-ID: <20190919171656.899649-36-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919171656.899649-1-anthony.perard@citrix.com> References: <20190919171656.899649-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 35/35] libxl_pci: Extract common part of *qemu_trad_watch_state_cb X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Functions pci_add_qemu_trad_watch_state_cb and pci_remove_qemu_trad_watch_state_cb are similar so the common part is extracted in a different function. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- Notes: v2: - new patch which attempt to combine the "basically-identical" functions pci_{add,remove}_qemu_trad_watch_state_cb tools/libxl/libxl_pci.c | 51 +++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 2c4e2e5cff5e..47258177bc71 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -984,6 +984,27 @@ static int qemu_pci_add_xenstore(libxl__gc *gc, uint32= _t domid, return rc; } =20 +static int check_qemu_running(libxl__gc *gc, + libxl_domid domid, + libxl__xswait_state *xswa, + int rc, + const char *state) +{ + if (rc) { + if (rc =3D=3D ERROR_TIMEDOUT) { + LOGD(ERROR, domid, "%s not ready", xswa->what); + } + goto out; + } + + if (!state || strcmp(state, "running")) + return ERROR_NOT_READY; + +out: + libxl__xswait_stop(gc, xswa); + return rc; +} + typedef struct pci_add_state { /* filled by user of do_pci_add */ libxl__ao_device *aodev; @@ -1071,21 +1092,14 @@ static void pci_add_qemu_trad_watch_state_cb(libxl_= _egc *egc, libxl_domid domid =3D pas->domid; libxl_device_pci *pcidev =3D pas->pcidev; =20 - if (rc) { - if (rc =3D=3D ERROR_TIMEDOUT) { - LOGD(ERROR, domid, "%s not ready", xswa->what); - } - goto out; - } - - if (!state) - return; - if (strcmp(state, "running")) + rc =3D check_qemu_running(gc, domid, xswa, rc, state); + if (rc =3D=3D ERROR_NOT_READY) return; + if (rc) + goto out; =20 rc =3D qemu_pci_add_xenstore(gc, domid, pcidev); out: - libxl__xswait_stop(gc, xswa); pci_add_dm_done(egc, pas, rc); /* must be last */ } =20 @@ -1893,22 +1907,15 @@ static void pci_remove_qemu_trad_watch_state_cb(lib= xl__egc *egc, libxl_domid domid =3D prs->domid; libxl_device_pci *const pcidev =3D prs->pcidev; =20 - if (rc) { - if (rc =3D=3D ERROR_TIMEDOUT) { - LOGD(ERROR, domid, "%s not ready", xswa->what); - } - goto out; - } - - if (!state) - return; - if (strcmp(state, "running")) + rc =3D check_qemu_running(gc, domid, xswa, rc, state); + if (rc =3D=3D ERROR_NOT_READY) return; + if (rc) + goto out; =20 rc =3D qemu_pci_remove_xenstore(gc, domid, pcidev, prs->force); =20 out: - libxl__xswait_stop(gc, xswa); pci_remove_detatched(egc, prs, rc); } =20 --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel