From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564760251; cv=none; d=zoho.com; s=zohoarc; b=Zw/U/8cIQnbikR8eFOQlr0PzK5WT65G458e98oe6Hrrtu1Df2XMiwHOiZiJzm7PjmjVmZDXubmRBQ1CiGAYB726PEDoYiesrdmpxKzArv4Kmbkz015/iDzq0R/4VgET5S/S2bTevUkYSciZmpQFR7dI1VvgflCXrn2ZVE/8gF3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564760251; 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=+YWwmRauitl/bJy0AL/bC8+MxkXODFJLmDA3iViTC3I=; b=eVNpzpnDGaeKytAhnj6Y0AG224u9LI80bh2E2beVvRIBP4zhJJuawLoPyqIvfqMptM9O8p4LaRcqxJyLtKbqmqfA0fssHT5vlRzjd2Oi+rRIfHfWCzKOXqcNn5vR8x1GxSIUPpPq11+JkhBeXZ69Jymp+oclz6KmEn/6c6z4tMc= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564760251812866.7116494044343; Fri, 2 Aug 2019 08:37:31 -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 1htZbN-00036j-Vd; Fri, 02 Aug 2019 15:36:17 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZbM-00034i-JR for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:36:16 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 430044fd-b53b-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:36:14 +0000 (UTC) X-Inumbo-ID: 430044fd-b53b-11e9-8980-bc764e045a96 Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: rtPpRBmXn6T/tvIvnAEfe2fkjT0aukz8tD9q9wzQylqDR+mTLVis9pmV5+Z1BiGsQdyMbDKuz5 ZF9uHeQzLDUODlbpUI4IGlYMooEYhXR1uwMaBDR8p8Nkfqosqa57gDWTYSsYGVSMtLvrUCmNQU o2vcF4g8Vagp3dZm64IXDR/HL27BvudIwiv+wMbJFRNM6XmtC6B22/0xhlTl0vF5+0rHeuBvNu IRC0JCzrTG7Wyy21zAmI/LcY1oKd4Pag/zAhIMrVZ4kkDmdW8dk2m6Ks8lHe0zLzBxvCo0Z44W TAQ= X-SBRS: 2.7 X-MesageID: 3825677 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3825677" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:32 +0100 Message-ID: <20190802153606.32061-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 01/35] libxl: Make libxl_domain_unpause async 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" libxl_domain_unpause needs to make QMP calls, which are asynchronous, change the API to reflect that. Do the same with libxl_domain_pause async, even if it will keep completing synchronously. Also fix some coding style issue in those functions. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl.h | 26 +++++++++++++++-- tools/libxl/libxl_colo_restore.c | 2 +- tools/libxl/libxl_colo_save.c | 2 +- tools/libxl/libxl_dm.c | 2 +- tools/libxl/libxl_domain.c | 48 +++++++++++++++++++++----------- tools/libxl/libxl_internal.h | 1 + tools/xl/xl_migrate.c | 4 +-- tools/xl/xl_saverestore.c | 2 +- tools/xl/xl_vmcontrol.c | 6 ++-- 9 files changed, 65 insertions(+), 28 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index e40546c23a..7a31169611 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -619,7 +619,8 @@ typedef struct libxl__ctx libxl_ctx; /* API compatibility. */ #ifdef LIBXL_API_VERSION #if LIBXL_API_VERSION !=3D 0x040200 && LIBXL_API_VERSION !=3D 0x040300 && \ - LIBXL_API_VERSION !=3D 0x040400 && LIBXL_API_VERSION !=3D 0x040500 + LIBXL_API_VERSION !=3D 0x040400 && LIBXL_API_VERSION !=3D 0x040500 && \ + LIBXL_API_VERSION !=3D 0x041300 #error Unknown LIBXL_API_VERSION #endif #endif @@ -1595,8 +1596,27 @@ int libxl_domain_rename(libxl_ctx *ctx, uint32_t dom= id, * transactionally that the domain has the old old name; if * trans is not 0 we use caller's transaction and caller must do retries= */ =20 -int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid); -int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid); +int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300 +static inline int libxl_domain_pause_0x041200( + libxl_ctx *ctx, uint32_t domid) +{ + return libxl_domain_pause(ctx, domid, NULL); +} +static inline int libxl_domain_unpause_0x041200( + libxl_ctx *ctx, uint32_t domid) +{ + return libxl_domain_unpause(ctx, domid, NULL); +} +#define libxl_domain_pause libxl_domain_pause_0x041200 +#define libxl_domain_unpause libxl_domain_unpause_0x041200 +#endif + =20 int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t domid, const char *filename, diff --git a/tools/libxl/libxl_colo_restore.c b/tools/libxl/libxl_colo_rest= ore.c index 0c535bd95d..aaa70552b8 100644 --- a/tools/libxl/libxl_colo_restore.c +++ b/tools/libxl/libxl_colo_restore.c @@ -853,7 +853,7 @@ static void colo_unpause_svm(libxl__egc *egc, EGC_GC; =20 /* We have enabled secondary vm's logdirty, so we can unpause it now */ - rc =3D libxl_domain_unpause(CTX, domid); + rc =3D libxl__domain_unpause(gc, domid); if (rc) { LOGD(ERROR, domid, "cannot unpause secondary vm"); goto out; diff --git a/tools/libxl/libxl_colo_save.c b/tools/libxl/libxl_colo_save.c index 3247cce3a7..1d261a1639 100644 --- a/tools/libxl/libxl_colo_save.c +++ b/tools/libxl/libxl_colo_save.c @@ -480,7 +480,7 @@ static void colo_preresume_cb(libxl__egc *egc, * no disk migration. */ if (css->paused) { - rc =3D libxl_domain_unpause(CTX, dss->domid); + rc =3D libxl__domain_unpause(gc, dss->domid); if (rc) { LOGD(ERROR, dss->domid, "cannot unpause primary vm"); goto out; diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 5fe25b56f5..00da59153d 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2402,7 +2402,7 @@ static void stubdom_pvqemu_cb(libxl__egc *egc, goto out; } =20 - rc =3D libxl_domain_unpause(CTX, dm_domid); + rc =3D libxl__domain_unpause(gc, dm_domid); if (rc) goto out; =20 sdss->xswait.ao =3D ao; diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 11a29b235b..1c313005db 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -557,18 +557,18 @@ int libxl_domain_suspend_only(libxl_ctx *ctx, uint32_= t domid, return AO_CREATE_FAIL(rc); } =20 -int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid) +int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid, + const libxl_asyncop_how *ao_how) { - int ret; - GC_INIT(ctx); - ret =3D xc_domain_pause(ctx->xch, domid); - if (ret<0) { + AO_CREATE(ctx, domid, ao_how); + int r; + r =3D xc_domain_pause(ctx->xch, domid); + if (r < 0) { LOGED(ERROR, domid, "Pausing domain"); - GC_FREE; - return ERROR_FAIL; + return AO_CREATE_FAIL(ERROR_FAIL); } - GC_FREE; - return 0; + libxl__ao_complete(egc, ao, 0); + return AO_INPROGRESS; } =20 int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t domid, @@ -593,10 +593,9 @@ int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t do= mid, return AO_INPROGRESS; } =20 -int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid) +int libxl__domain_unpause(libxl__gc *gc, libxl_domid domid) { - GC_INIT(ctx); - int ret, rc =3D 0; + int r, rc; =20 libxl_domain_type type =3D libxl__domain_type(gc, domid); if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) { @@ -612,16 +611,33 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t dom= id) goto out; } } - ret =3D xc_domain_unpause(ctx->xch, domid); - if (ret<0) { + r =3D xc_domain_unpause(CTX->xch, domid); + if (r < 0) { LOGED(ERROR, domid, "Unpausing domain"); rc =3D ERROR_FAIL; + goto out; } - out: - GC_FREE; + rc =3D 0; +out: return rc; } =20 +int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid, + const libxl_asyncop_how *ao_how) +{ + AO_CREATE(ctx, domid, ao_how); + int rc =3D 0; + + rc =3D libxl__domain_unpause(gc, domid); + if (rc) goto out; + + libxl__ao_complete(egc, ao, rc); + return AO_INPROGRESS; + + out: + return AO_CREATE_FAIL(rc); +} + int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid) { libxl_ctx *ctx =3D libxl__gc_owner(gc); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index cf9287c488..7bd08032cf 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -4108,6 +4108,7 @@ _hidden void libxl__remus_teardown(libxl__egc *egc, int rc); _hidden void libxl__remus_restore_setup(libxl__egc *egc, libxl__domain_create_state *dcs); +_hidden int libxl__domain_unpause(libxl__gc *, libxl_domid domid); =20 =20 /* diff --git a/tools/xl/xl_migrate.c b/tools/xl/xl_migrate.c index 1f0e87df50..22f0429b84 100644 --- a/tools/xl/xl_migrate.c +++ b/tools/xl/xl_migrate.c @@ -394,7 +394,7 @@ static void migrate_receive(int debug, int daemonize, i= nt monitor, /* The guest is running after failover in COLO mode */ exit(rc ? -ERROR_FAIL: 0); =20 - rc =3D libxl_domain_unpause(ctx, domid); + rc =3D libxl_domain_unpause(ctx, domid, NULL); if (rc) fprintf(stderr, "migration target (%s): " "Failed to unpause domain %s (id: %u):%d\n", @@ -429,7 +429,7 @@ static void migrate_receive(int debug, int daemonize, i= nt monitor, } =20 if (!pause_after_migration) { - rc =3D libxl_domain_unpause(ctx, domid); + rc =3D libxl_domain_unpause(ctx, domid, NULL); if (rc) goto perhaps_destroy_notify_rc; } =20 diff --git a/tools/xl/xl_saverestore.c b/tools/xl/xl_saverestore.c index 9afeadeeb2..5c70e2e874 100644 --- a/tools/xl/xl_saverestore.c +++ b/tools/xl/xl_saverestore.c @@ -150,7 +150,7 @@ static int save_domain(uint32_t domid, const char *file= name, int checkpoint, } else if (leavepaused || checkpoint) { if (leavepaused) - libxl_domain_pause(ctx, domid); + libxl_domain_pause(ctx, domid, NULL); libxl_domain_resume(ctx, domid, 1, 0); } else diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index a1d633795c..419bf780a4 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -34,12 +34,12 @@ static int fd_lock =3D -1; =20 static void pause_domain(uint32_t domid) { - libxl_domain_pause(ctx, domid); + libxl_domain_pause(ctx, domid, NULL); } =20 static void unpause_domain(uint32_t domid) { - libxl_domain_unpause(ctx, domid); + libxl_domain_unpause(ctx, domid, NULL); } =20 static void destroy_domain(uint32_t domid, int force) @@ -972,7 +972,7 @@ int create_domain(struct domain_create *dom_info) } =20 if (!paused) - libxl_domain_unpause(ctx, domid); + libxl_domain_unpause(ctx, domid, NULL); =20 ret =3D domid; /* caller gets success in parent */ if (!daemonize && !monitor) --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564760241; cv=none; d=zoho.com; s=zohoarc; b=P3wdP/I/S0f+/20sC4jy2N+T0d8EbXxjDoPslC98cgv0SkV6Vdj8yWP0y2ZlRIyt0oJC7RiAgLoGL5xleGoh9a+nBOyIvYsLEwGtaqyQy7u8Xxn0fmjm8S/GQWUNuvP9HrGm2nYmupDfSal2UOMl5Bk6LjjqMlfHwpyJUAxbpxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564760241; 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=CtKRshlMsbDM1QbgR4sSUltcXPfb63u823Yv35P3I0E=; b=LQKSpLfj0pMz/FVwHYEtIMvBOdf95cmrwZV9O/daHBQetSX9/SzvjNexmliS5fGJsQvPtpJwZRz3AZBGJWn8zMOFaoRoyj0g5JSq01To9npmGrVkj+nOu7JqyIID2axYQRRCcE4OS3eppAKwTxCrmkicq6DukHjYDA1Y5jz5EVY= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564760241934609.8384575419615; Fri, 2 Aug 2019 08:37:21 -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 1htZbJ-00032v-Ay; Fri, 02 Aug 2019 15:36:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZbH-00032M-L0 for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:36:11 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 402268c3-b53b-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:36:09 +0000 (UTC) X-Inumbo-ID: 402268c3-b53b-11e9-8980-bc764e045a96 Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: LTrPfIHvPJyaLQm7Hg7lDDlN/giksmwG8uKsrq/lgh8/0pz3p5U1XXlFCQ6cce93u0iu0BAvSS vA/LwXkMGDBQeFVDlJ/n3qly+5d38NW2J7DJwSJka41ZTKaupLhrPReLoLB3MRaMF5FaZMGU0q +LOURgpZITutoc1kxoXNYfRmgRs0AA2/bioix081NhYujmBphoZ58axjs7n8LnG/9ArT+YkJgt ljES/K+pJG/bi0yJpwNaHolyx//Z34GWdtUfPUooEtHXC1yq0vvq2mwQrxl6iK6h6jPSWrN0Ez 6eQ= X-SBRS: 2.7 X-MesageID: 3825667 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3825667" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:33 +0100 Message-ID: <20190802153606.32061-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 02/35] libxl: Make libxl_send_trigger async 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" .. because it makes QMP calls which are going to be async. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl.h | 12 +++++++++++- tools/libxl/libxl_domain.c | 12 ++++++++---- tools/xl/xl_misc.c | 4 ++-- tools/xl/xl_vmcontrol.c | 4 ++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 7a31169611..0164d93adf 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -2350,7 +2350,17 @@ int libxl_vcpu_sched_params_set_all(libxl_ctx *ctx, = uint32_t domid, const libxl_vcpu_sched_params *params); =20 int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid, - libxl_trigger trigger, uint32_t vcpuid); + libxl_trigger trigger, uint32_t vcpuid, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300 +static inline int libxl_send_trigger_0x041200( + libxl_ctx *ctx, uint32_t domid, libxl_trigger trigger, uint32_t vcpuid) +{ + return libxl_send_trigger_0x041200(ctx, domid, trigger, vcpuid, NULL); +} +#define libxl_send_trigger libxl_send_trigger_0x041200 +#endif int libxl_send_sysrq(libxl_ctx *ctx, uint32_t domid, char sysrq); int libxl_send_debug_keys(libxl_ctx *ctx, char *keys); int libxl_set_parameters(libxl_ctx *ctx, char *params); diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 1c313005db..86cddc05a9 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1470,10 +1470,11 @@ static int libxl__domain_s3_resume(libxl__gc *gc, i= nt domid) } =20 int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid, - libxl_trigger trigger, uint32_t vcpuid) + libxl_trigger trigger, uint32_t vcpuid, + const libxl_asyncop_how *ao_how) { + AO_CREATE(ctx, domid, ao_how); int rc; - GC_INIT(ctx); =20 switch (trigger) { case LIBXL_TRIGGER_POWER: @@ -1509,10 +1510,13 @@ int libxl_send_trigger(libxl_ctx *ctx, uint32_t dom= id, LOGED(ERROR, domid, "Send trigger '%s' failed", libxl_trigger_to_string(trigger)); rc =3D ERROR_FAIL; + goto out; } =20 - GC_FREE; - return rc; + libxl__ao_complete(egc, ao, rc); + return AO_INPROGRESS; +out: + return AO_CREATE_FAIL(rc); } =20 uint32_t libxl_vm_get_start_time(libxl_ctx *ctx, uint32_t domid) diff --git a/tools/xl/xl_misc.c b/tools/xl/xl_misc.c index dcf940a6d4..50c8436337 100644 --- a/tools/xl/xl_misc.c +++ b/tools/xl/xl_misc.c @@ -36,7 +36,7 @@ static void button_press(uint32_t domid, const char *b) exit(EXIT_FAILURE); } =20 - libxl_send_trigger(ctx, domid, trigger, 0); + libxl_send_trigger(ctx, domid, trigger, 0, NULL); } =20 int main_button_press(int argc, char **argv) @@ -106,7 +106,7 @@ int main_trigger(int argc, char **argv) } } =20 - libxl_send_trigger(ctx, domid, trigger, vcpuid); + libxl_send_trigger(ctx, domid, trigger, vcpuid, NULL); =20 return EXIT_SUCCESS; } diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 419bf780a4..3fc6f56574 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -108,7 +108,7 @@ static void reboot_domain(uint32_t domid, libxl_evgen_d= omain_death **deathw, if (fallback_trigger) { fprintf(stderr, "PV control interface not available:" " sending ACPI reset button event.\n"); - rc =3D libxl_send_trigger(ctx, domid, LIBXL_TRIGGER_RESET, 0); + rc =3D libxl_send_trigger(ctx, domid, LIBXL_TRIGGER_RESET, 0, = NULL); } else { fprintf(stderr, "PV control interface not available:" " external graceful reboot not possible.\n"); @@ -141,7 +141,7 @@ static void shutdown_domain(uint32_t domid, if (fallback_trigger) { fprintf(stderr, "PV control interface not available:" " sending ACPI power button event.\n"); - rc =3D libxl_send_trigger(ctx, domid, LIBXL_TRIGGER_POWER, 0); + rc =3D libxl_send_trigger(ctx, domid, LIBXL_TRIGGER_POWER, 0, = NULL); } else { fprintf(stderr, "PV control interface not available:" " external graceful shutdown not possible.\n"); --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564760240; cv=none; d=zoho.com; s=zohoarc; b=oXwEH+HIeB1tCd8JXY0HD5aNoH0Sp1FZlJslp7/EYMHddFYPF0ZtDBfcZcJua4jWl2J94F+rdl/iU16LgKxFA8y8RJ5VmznFf+nJg7UbbtcHLwm/Zm4W3gErTZEzoMMtmNn5ZOmHUZSA0pBeEPgFedheiwcO2O4GfgfeCrv+BnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564760240; 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=5rJL9NjpYumgLwuGym80zgyGghf9TK1Hk0ha8Z5Q9ss=; b=CPYE+bKY5feSSIIPUs6UlYA5zGSwBpXwBfh1wQDKaes24PkTfUX+kNlHYHb/nYn+dfPseW/xacoYTGX4jR4qVDpvV22I8rO/tlptcRwT/cl64sMEEEog8rFOq13sbGPUIArr/aeoAABpIrtNk43/0uo0/A8x7vw21LvPo+w+db8= ARC-Authentication-Results: i=1; mx.zoho.com; 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 15647602402041018.8634146967805; Fri, 2 Aug 2019 08:37:20 -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 1htZbJ-00032p-1v; Fri, 02 Aug 2019 15:36:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZbH-00032L-K3 for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:36:11 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 40cc03d6-b53b-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:36:10 +0000 (UTC) X-Inumbo-ID: 40cc03d6-b53b-11e9-8980-bc764e045a96 Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: n65uTvD2AdDmT0zmnaVGCgaKo7+N7xtrBAt+XoVhcwIjYEfcY821bc4NyD1A8mJ+okZI1RnYR0 vxC2JExWp1IrBl4fdUtDmR2vt1V51IP68CnAR7+/m8g+LY5Rv45uUc4CaEapzlzRO2kbfCGDDG BPqExrpZGJVTczMThtkAXsW4R6zvNWKwYyeHengo33dDy0O8Sf1DwXoeCLpbyK48d3AHvxYjh4 I+/YW+ODIQv3vkjcNSROZEvuyZnlJX1dRm2O/9/TruhxxdNYe0Q08GqXrUC86rL1DLxE8/ETx0 JKY= X-SBRS: 2.7 X-MesageID: 3825668 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3825668" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:34 +0100 Message-ID: <20190802153606.32061-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 03/35] libxl: Make libxl_set_vcpuonline async 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" .. because it makes QMP calls which are going to be async. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl.h | 14 +++++++++++++- tools/libxl/libxl_domain.c | 12 ++++++++---- tools/xl/xl_cpupool.c | 2 +- tools/xl/xl_vcpu.c | 2 +- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 0164d93adf..224c9af1c6 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -2287,7 +2287,19 @@ int libxl_domain_set_nodeaffinity(libxl_ctx *ctx, ui= nt32_t domid, libxl_bitmap *nodemap); int libxl_domain_get_nodeaffinity(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *nodemap); -int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpu= map); +int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, + libxl_bitmap *cpumap, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300 +static inline int libxl_set_vcpuonline_0x041200(libxl_ctx *ctx, + uint32_t domid, + libxl_bitmap *cpumap) +{ + return libxl_set_vcpuonline(ctx, domid, cpumap, NULL); +} +#define libxl_set_vcpuonline libxl_set_vcpuonline_0x041200 +#endif =20 /* A return value less than 0 should be interpreted as a libxl_error, whil= e a * return value greater than or equal to 0 should be interpreted as a diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 86cddc05a9..60c3f7a34b 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1386,9 +1386,11 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, = uint32_t domid, return rc; } =20 -int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpu= map) +int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, + libxl_bitmap *cpumap, + const libxl_asyncop_how *ao_how) { - GC_INIT(ctx); + AO_CREATE(ctx, domid, ao_how); int rc, maxcpus; libxl_dominfo info; =20 @@ -1439,8 +1441,10 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t do= mid, libxl_bitmap *cpumap) =20 out: libxl_dominfo_dispose(&info); - GC_FREE; - return rc; + if (rc) + return AO_CREATE_FAIL(rc); + libxl__ao_complete(egc, ao, rc); + return AO_INPROGRESS; } =20 static int libxl__domain_s3_resume(libxl__gc *gc, int domid) diff --git a/tools/xl/xl_cpupool.c b/tools/xl/xl_cpupool.c index 273811b663..cffe87e0c7 100644 --- a/tools/xl/xl_cpupool.c +++ b/tools/xl/xl_cpupool.c @@ -546,7 +546,7 @@ int main_cpupoolnumasplit(int argc, char **argv) fprintf(stderr, "error on getting info for Domain-0\n"); goto out; } - if (info.vcpu_online > n && libxl_set_vcpuonline(ctx, 0, &cpumap)) { + if (info.vcpu_online > n && libxl_set_vcpuonline(ctx, 0, &cpumap, NULL= )) { fprintf(stderr, "error on removing vcpus for Domain-0\n"); goto out; } diff --git a/tools/xl/xl_vcpu.c b/tools/xl/xl_vcpu.c index 329512eaaf..9ff5354f74 100644 --- a/tools/xl/xl_vcpu.c +++ b/tools/xl/xl_vcpu.c @@ -369,7 +369,7 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus= , int check_host) for (i =3D 0; i < max_vcpus; i++) libxl_bitmap_set(&cpumap, i); =20 - rc =3D libxl_set_vcpuonline(ctx, domid, &cpumap); + rc =3D libxl_set_vcpuonline(ctx, domid, &cpumap, NULL); if (rc =3D=3D ERROR_DOMAIN_NOTFOUND) fprintf(stderr, "Domain %u does not exist.\n", domid); else if (rc) --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564760240; cv=none; d=zoho.com; s=zohoarc; b=aDuLFvNyzPEJ8KdHFjKVGCz6CHF2v9vwCZz2A5jJ8GGiRM0SXqIK5yCGZo8FkckmnXHH0bvzuIA6DWdfwI4eV5NeGWjbRjqRcgpbAg6KlPCmvjgPmB9LjMqJwsZYfYOQ8o9T/NX0Kwmf2uHRdkDaQfXmAO51rsg09uo/4jwP+os= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564760240; 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=MnL+U6+gj/Bce9ILVUR6Djbb8FWm17vYSenzsHfyEe0=; b=cFN3+zze6XGhHeNZgkO4py37u1jgucklD5wjp1tfG4diNxWPFDq+hTqF1i652mqHSnNC1TbpP3lGq2Fk+ffvhewQEURZLnLG8bW0wTuMPxs/4rvzt/705TN+P+lkbv6HJQ2nTaXDMlnNC7mIOwm1Qt88hsKuq4DitWv7MWmr/Lw= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564760240193173.88543653079034; Fri, 2 Aug 2019 08:37:20 -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 1htZbJ-000336-NM; Fri, 02 Aug 2019 15:36:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZbH-00032Z-Tl for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:36:11 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 40c2365c-b53b-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:36:11 +0000 (UTC) X-Inumbo-ID: 40c2365c-b53b-11e9-8980-bc764e045a96 Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: geMqhCiz6YsLai/a3Mh5JW9ggx7whFKc6vA6/9AQB+NRp9o+9dMxCyEsWFFYlRoWq96edO9/3A 0fnuJ625KECdzOCNmy/7tupXqrAdJt3M5MaZjGEVyEuDFGkETffBma7Wur1lWBiEW0QcjElAxu HaXdQgX+EG5MvfTat4Ba94WasdHztig/HV1yVGfjJSHvQIe+EO7WSvmfWX7TUMaNVFOIWe57vB neZcln4+zsSaFECXm7JGKAfTt3GvxWNxHCJFXmo7izYAW38P5NMStHHQORcEOpJyqIwQeWyr8Q Cws= X-SBRS: 2.7 X-MesageID: 3825669 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3825669" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:35 +0100 Message-ID: <20190802153606.32061-5-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 04/35] libxl: Make libxl_retrieve_domain_configuration async 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" .. because it makes QMP calls which are going to be async. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl.h | 12 +++++++++++- tools/libxl/libxl_domain.c | 14 +++++++------- tools/xl/xl_info.c | 3 ++- tools/xl/xl_saverestore.c | 3 ++- tools/xl/xl_vmcontrol.c | 3 ++- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 224c9af1c6..96489a74ca 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -1532,8 +1532,18 @@ void libxl_domain_config_dispose(libxl_domain_config= *d_config); * works with DomU. */ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, - libxl_domain_config *d_config) + libxl_domain_config *d_config, + const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; +#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300 +static inline int libxl_retrieve_domain_configuration_0x041200( + libxl_ctx *ctx, uint32_t domid, libxl_domain_config *d_config) +{ + return libxl_retrieve_domain_configuration(ctx, domid, d_config, NULL); +} +#define libxl_retrieve_domain_configuration \ + libxl_retrieve_domain_configuration_0x041200 +#endif =20 int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags, /* LIBXL_SUSPEND_* */ diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 60c3f7a34b..f2d5c86427 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1594,14 +1594,13 @@ static int libxl__update_avail_vcpus_xenstore(libxl= __gc *gc, uint32_t domid, } =20 int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, - libxl_domain_config *d_config) + libxl_domain_config *d_config, + const libxl_asyncop_how *ao_how) { - GC_INIT(ctx); + AO_CREATE(ctx, domid, ao_how); int rc; libxl__domain_userdata_lock *lock =3D NULL; =20 - CTX_LOCK; - lock =3D libxl__lock_domain_userdata(gc, domid); if (!lock) { rc =3D ERROR_LOCK_FAIL; @@ -1808,9 +1807,10 @@ int libxl_retrieve_domain_configuration(libxl_ctx *c= tx, uint32_t domid, =20 out: if (lock) libxl__unlock_domain_userdata(lock); - CTX_UNLOCK; - GC_FREE; - return rc; + if (rc) + return AO_CREATE_FAIL(rc); + libxl__ao_complete(egc, ao, rc); + return AO_INPROGRESS; } =20 /* diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c index 46d9c9f712..74a7884479 100644 --- a/tools/xl/xl_info.c +++ b/tools/xl/xl_info.c @@ -461,7 +461,8 @@ static void list_domains_details(const libxl_dominfo *i= nfo, int nb_domain) =20 for (i =3D 0; i < nb_domain; i++) { libxl_domain_config_init(&d_config); - rc =3D libxl_retrieve_domain_configuration(ctx, info[i].domid, &d_= config); + rc =3D libxl_retrieve_domain_configuration(ctx, info[i].domid, + &d_config, NULL); if (rc) continue; if (default_output_format =3D=3D OUTPUT_FORMAT_JSON) diff --git a/tools/xl/xl_saverestore.c b/tools/xl/xl_saverestore.c index 5c70e2e874..9be033fe65 100644 --- a/tools/xl/xl_saverestore.c +++ b/tools/xl/xl_saverestore.c @@ -56,7 +56,8 @@ void save_domain_core_begin(uint32_t domid, &d_config); free(config_v); } else { - rc =3D libxl_retrieve_domain_configuration(ctx, domid, &d_config); + rc =3D libxl_retrieve_domain_configuration(ctx, domid, &d_config, + NULL); if (rc) { fprintf(stderr, "unable to retrieve domain configuration\n"); exit(EXIT_FAILURE); diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 3fc6f56574..eb6779a561 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -377,7 +377,8 @@ static void reload_domain_config(uint32_t domid, } =20 libxl_domain_config_init(&d_config_new); - rc =3D libxl_retrieve_domain_configuration(ctx, domid, &d_config_new); + rc =3D libxl_retrieve_domain_configuration(ctx, domid, &d_config_new, + NULL); if (rc) { LOG("failed to retrieve guest configuration (rc=3D%d). " "reusing old configuration", rc); --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564760240; cv=none; d=zoho.com; s=zohoarc; b=ZcuBl5Iyj4O0G5mdpPHGw1z+0Le+mpA2t4otCYiVrz8/UIcqIa6+DT+S3U6bzY9UaFkqsdzfsVsK4pTAodeBqHLP/JWdZS1+i7LNeqvs3g0IViHhoR75riqIPYzlOBXFv2GsDhONCu2oO/TGDP7UHHPGbQuKhAbfd0ZgHPhUT/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564760240; 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=rjDo4oXnAG9rA6QYezIYNZpCVRY6cDkzLd4ajQg2woQ=; b=PUfCYErTukTPIADYeieyDW++wjoj6leoiRch126OTEV4iDjEy3JDl9Wcj9STnu61mj4wwWg0mr7pvtjLF20SpBT3v0sB7SR9r/O7jj8g/nubSF3E93B4ucVlfd8HaZIkLcd3v7N5na7ZUPeGBeBfTB99wt3HzrLwKhLKYB9GYIc= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564760240709218.92860950035742; Fri, 2 Aug 2019 08:37:20 -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 1htZbK-00033Q-5Q; Fri, 02 Aug 2019 15:36:14 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZbI-00032e-KS for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:36:12 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 412ba0c8-b53b-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:36:11 +0000 (UTC) X-Inumbo-ID: 412ba0c8-b53b-11e9-8980-bc764e045a96 Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Cs7Bp/KqHvffa+x9gtcZC2dDpcK2DMruxNhgQir7MNItRPU0foxlkerZ6DcIgmvukBNCIYBBLB lIFQqz/c0TCDwUD/NSeqN46Vg/Z01Tgjrha3ToMzRI0/qBi98LZGAPAtPi4eiP2mSATssKLZnF gmyQWQhv5thpkJlDJU1idkgWCq9MC91d6zZLqIhB4alBb8RHTA0FulYDAXYaPxaeFbRaAkc7wF JagG8DJUfAS0vDGOG+6MT2RJpnXzS8COUmXEaCq8EsGX73UlfM1lWNSjjmjUtcOKgIkoDvrCx/ /YM= X-SBRS: 2.7 X-MesageID: 3825670 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3825670" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:36 +0100 Message-ID: <20190802153606.32061-6-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 05/35] libxl: Make libxl_qemu_monitor_command async 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" .. because it makes QMP calls which are going to be async. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl.h | 13 ++++++++++++- tools/libxl/libxl_qmp.c | 9 +++++---- tools/xl/xl_misc.c | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 96489a74ca..d001ffc75e 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -2538,7 +2538,18 @@ int libxl_fd_set_nonblock(libxl_ctx *ctx, int fd, in= t nonblock); * via output. */ int libxl_qemu_monitor_command(libxl_ctx *ctx, uint32_t domid, - const char *command_line, char **output); + const char *command_line, char **output, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300 +static inline int libxl_qemu_monitor_command_0x041200(libxl_ctx *ctx, + uint32_t domid, const char *command_line, char **output) +{ + return libxl_qemu_monitor_command(ctx, domid, command_line, output, + NULL); +} +#define libxl_qemu_monitor_command libxl_qemu_monitor_command_0x041200 +#endif =20 #include =20 diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 20d9eed8dd..505e0e5469 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -1291,15 +1291,16 @@ int libxl__qmp_hmp(libxl__gc *gc, int domid, const = char *command_line, } =20 int libxl_qemu_monitor_command(libxl_ctx *ctx, uint32_t domid, - const char *command_line, char **output) + const char *command_line, char **output, + const libxl_asyncop_how *ao_how) { - GC_INIT(ctx); + AO_CREATE(ctx, domid, ao_how); int rc; =20 rc =3D libxl__qmp_hmp(gc, domid, command_line, output); =20 - GC_FREE; - return rc; + libxl__ao_complete(egc, ao, rc); + return AO_INPROGRESS; } =20 int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid, diff --git a/tools/xl/xl_misc.c b/tools/xl/xl_misc.c index 50c8436337..20ed605f4f 100644 --- a/tools/xl/xl_misc.c +++ b/tools/xl/xl_misc.c @@ -228,7 +228,7 @@ int main_qemu_monitor_command(int argc, char **argv) return EXIT_FAILURE; } =20 - ret =3D libxl_qemu_monitor_command(ctx, domid, cmd, &output); + ret =3D libxl_qemu_monitor_command(ctx, domid, cmd, &output, NULL); if (!ret && output) { printf("%s\n", output); free(output); --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564760253; cv=none; d=zoho.com; s=zohoarc; b=FlrgpCnCl03zy20q+guCbD/KJBaOpFgsKtSpzAxT64T/um0GBf572+a8gvlojGcVzIHItr1jiEMfdQYfuBA5HhI+OQ15iTyq9AQRbC5UmblzqCBFa8LF2KlQ43rfew3D2gh2pt4HRjm5igG/TKMqmRCoEkPM2S2d+pgC6liU+eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564760253; 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=D0FgauvjdSI7p2Yu1JN0RP3yqa4jYs4ioNR5l3ig3yA=; b=RZVLQp9U3iWpUY+WPBOfoZIM396F9BjdUBRHVPS2Cwku76rcXxXKfK+VuqVPjiH1ti2Ai8ouT573wmrcZPjSHV6pXlgQNl6N0JWo95CZZ/tM8CpOGGHqvZFRz38EaIaQISS5xigdTYA+kv6K0wlxhwp+46eDPOEOWGN9HMbMmNI= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564760253009693.3918455185737; Fri, 2 Aug 2019 08:37:33 -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 1htZbd-0003Iw-CT; Fri, 02 Aug 2019 15:36:33 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZbc-0003I7-Fa for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:36:32 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 4ced3835-b53b-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:36:31 +0000 (UTC) X-Inumbo-ID: 4ced3835-b53b-11e9-8980-bc764e045a96 Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: qHN4Yt3Behz+pPhLlMfTRKCkcajJ+8Ao74zocPUZ88qn2/jldG14xyjUS2GUM6T5Ews8B8OSrm GZeFNVplDAM0hkr/vrXEEf/YNmo/LAEDljhg27W9IFMbvfw3ey93DG8pOwd/XU9w/MtW0UL0OC J/i/v6A05OhY/5ROfrOshVAUXuiAONqBxEzd4Izts4EkURJTM38vR39vzRs3lDNaGab1DW+BLZ Hwu3HBmn5MchPM8tm3mdCo6LRiSPS1tXSD1Sp1/1fLWaZiMGY5kWcdyzpOJGLaaqJbsKotNf0I P4Q= X-SBRS: 2.7 X-MesageID: 3796634 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3796634" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:37 +0100 Message-ID: <20190802153606.32061-7-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 06/35] libxl: Use ev_qmp for switch_qemu_xen_logdirty 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" Signed-off-by: Anthony PERARD --- tools/libxl/libxl_dom_save.c | 41 ++++++++++++++++++++++++++++++++---- tools/libxl/libxl_internal.h | 3 +-- tools/libxl/libxl_qmp.c | 10 --------- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/tools/libxl/libxl_dom_save.c b/tools/libxl/libxl_dom_save.c index 13d08d6dae..e70aa15859 100644 --- a/tools/libxl/libxl_dom_save.c +++ b/tools/libxl/libxl_dom_save.c @@ -44,6 +44,10 @@ static void switch_logdirty_xswatch(libxl__egc *egc, lib= xl__ev_xswatch*, static void domain_suspend_switch_qemu_xen_logdirty (libxl__egc *egc, int domid, unsigned enabl= e, libxl__logdirty_switch *lds); +static void switch_qemu_xen_logdirty_done(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *, + int rc); static void switch_logdirty_timeout(libxl__egc *egc, libxl__ev_time *ev, const struct timeval *requested_abs, int rc); @@ -55,6 +59,7 @@ void libxl__logdirty_init(libxl__logdirty_switch *lds) lds->cmd_path =3D 0; libxl__ev_xswatch_init(&lds->watch); libxl__ev_time_init(&lds->timeout); + libxl__ev_qmp_init(&lds->qmp); } =20 void libxl__domain_common_switch_qemu_logdirty(libxl__egc *egc, @@ -207,13 +212,40 @@ static void domain_suspend_switch_qemu_xen_logdirty { STATE_AO_GC(lds->ao); int rc; + libxl__json_object *args =3D NULL; + + /* Convenience aliases. */ + libxl__ev_qmp *const qmp =3D &lds->qmp; + + rc =3D libxl__ev_time_register_rel(ao, &lds->timeout, + switch_logdirty_timeout, 10 * 1000); + if (rc) goto out; + + qmp->ao =3D ao; + qmp->domid =3D domid; + qmp->payload_fd =3D -1; + qmp->callback =3D switch_qemu_xen_logdirty_done; + libxl__qmp_param_add_bool(gc, &args, "enable", enable); + rc =3D libxl__ev_qmp_send(gc, qmp, "xen-set-global-dirty-log", args); + if (rc) goto out; + + return; +out: + switch_qemu_xen_logdirty_done(egc, qmp, NULL, rc); +} + +static void switch_qemu_xen_logdirty_done(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *r, + int rc) +{ + EGC_GC; + libxl__logdirty_switch *lds =3D CONTAINER_OF(qmp, *lds, qmp); =20 - rc =3D libxl__qmp_set_global_dirty_log(gc, domid, enable); if (rc) - LOGD(ERROR, domid, + LOGD(ERROR, qmp->domid, "logdirty switch failed (rc=3D%d), abandoning suspend",rc); - - lds->callback(egc, lds, rc); + switch_logdirty_done(egc, lds, rc); } =20 static void switch_logdirty_timeout(libxl__egc *egc, libxl__ev_time *ev, @@ -234,6 +266,7 @@ static void switch_logdirty_done(libxl__egc *egc, =20 libxl__ev_xswatch_deregister(gc, &lds->watch); libxl__ev_time_deregister(gc, &lds->timeout); + libxl__ev_qmp_dispose(gc, &lds->qmp); =20 lds->callback(egc, lds, rc); } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 7bd08032cf..effc1c5bf9 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1957,8 +1957,6 @@ _hidden int libxl__qmp_system_wakeup(libxl__gc *gc, i= nt domid); _hidden int libxl__qmp_resume(libxl__gc *gc, int domid); /* Load current QEMU state from file. */ _hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filen= ame); -/* Set dirty bitmap logging status */ -_hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool= enable); /* Add a virtual CPU */ _hidden int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int index); /* Query the bitmap of CPUs */ @@ -3412,6 +3410,7 @@ typedef struct libxl__logdirty_switch { const char *ret_path; libxl__ev_xswatch watch; libxl__ev_time timeout; + libxl__ev_qmp qmp; } libxl__logdirty_switch; =20 _hidden void libxl__logdirty_init(libxl__logdirty_switch *lds); diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 505e0e5469..f1529925ee 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -1108,16 +1108,6 @@ int libxl__qmp_resume(libxl__gc *gc, int domid) return qmp_run_command(gc, domid, "cont", NULL, NULL, NULL); } =20 -int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable) -{ - libxl__json_object *args =3D NULL; - - libxl__qmp_param_add_bool(gc, &args, "enable", enable); - - return qmp_run_command(gc, domid, "xen-set-global-dirty-log", args, - NULL, NULL); -} - int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int idx) { libxl__json_object *args =3D NULL; --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564760241; cv=none; d=zoho.com; s=zohoarc; b=mKXx2pdNia6OTrYusmqmHcMXpzYB3n8MFOezYFmekgCwCNicwzNRspLb1REv8FpwpfShrQ03JNfIDKQIMsghfqe8/8ZcQ+zflLSRMqN+MBPzekKdovmp7AciViCvIm4f3m5t+Vh8mgAGC+3sW8nXkNxcXCnqq+h8eB5Eie6UtuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564760241; 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=WVV2iuiXuZJJ63piFoDDZjiD1SppU5kFxbJ737qsqbM=; b=WUbDTcR8z8W30sMTL6qpr7p/LFg4PcSjJrlqdFvAUik/zCMTT8Bro+sWUGJhFvTyKxaO3DoPAzrb8Y4iMr2MpV0auiTQwil7Wn4KjH2uCWe46NEPda2TEBSdVgyUpk1BAAzJei5oWQFhgum1EgkbgNCF+kJgl5aAVdJqnZ+fAvU= ARC-Authentication-Results: i=1; mx.zoho.com; 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 156476024126555.78921603745118; Fri, 2 Aug 2019 08:37:21 -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 1htZbI-00032g-PH; Fri, 02 Aug 2019 15:36:12 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZbH-00032K-Id for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:36:11 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 40705e20-b53b-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:36:10 +0000 (UTC) X-Inumbo-ID: 40705e20-b53b-11e9-8980-bc764e045a96 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: NOMjw+w0X2lefXBHn54FoG+DJ22oVErXqVJmdQXPXky6HFSuYDE6KorpoUfx+WPLcLLnbm8OpA v9eWTb0E8U7ikjexwxpMJ0a1C/R3BI2yVYHrYNr+TWZPswpbXUQ8KZ83T3TDadCbZF9Sih+uvQ PJxXV42gKjypLjSVE42VW2mqIE5XLqIAtT1AcPgZY99371HIzcxW0SNDtGWWVzcFIwAsezMnp1 mTuXoSIjOyjqwl8bX2D9UATCdVmXbNcNr9kRGMxTQKgrsxNWomBaksF+8hvyn6jFuSwYdqM2pD VzQ= X-SBRS: 2.7 X-MesageID: 3950106 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,338,1559534400"; d="scan'208";a="3950106" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:38 +0100 Message-ID: <20190802153606.32061-8-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 07/35] libxl: Move "qmp_initializations" to libxl_dm 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" libxl__qmp_initializations is part of the device domain startup, it queries information about the newly spawned QEMU and do some post-startup configuration. So the function call doesn't belong to the general domain creation, but only to the device model part of the process, thus the call belong to libxl_dm and libxl__dm_spawn_state's machinery. We move the call ahead of a follow-up patch which going to "inline" libxl__qmp_initializations. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_create.c | 10 ---------- tools/libxl/libxl_dm.c | 8 ++++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 9f56851be2..7144d6ff53 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1543,21 +1543,11 @@ static void domcreate_devmodel_started(libxl__egc *= egc, STATE_AO_GC(dmss->spawn.ao); int domid =3D dcs->guest_domid; =20 - /* convenience aliases */ - libxl_domain_config *const d_config =3D dcs->guest_config; - if (ret) { LOGD(ERROR, domid, "device model did not start: %d", ret); goto error_out; } =20 - if (dcs->sdss.dm.guest_domid) { - if (d_config->b_info.device_model_version - =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { - libxl__qmp_initializations(gc, domid, d_config); - } - } - dcs->device_type_idx =3D -1; domcreate_attach_devices(egc, &dcs->multidev, 0); return; diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 00da59153d..5a2e349776 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2744,6 +2744,9 @@ static void device_model_spawn_outcome(libxl__egc *eg= c, STATE_AO_GC(dmss->spawn.ao); int ret2; =20 + /* Convenience aliases */ + libxl_domain_config *const d_config =3D dmss->guest_config; + if (rc) LOGD(ERROR, dmss->guest_domid, "%s: spawn failed (rc=3D%d)", dmss->spawn.what, rc); @@ -2760,6 +2763,11 @@ static void device_model_spawn_outcome(libxl__egc *e= gc, } } =20 + if (d_config->b_info.device_model_version + =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { + libxl__qmp_initializations(gc, dmss->guest_domid, d_config); + } + out: dmss_dispose(gc, dmss); dmss->callback(egc, dmss, rc); --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564760259; cv=none; d=zoho.com; s=zohoarc; b=nr/hxSw1R5gu4n51GjLQtUHg7+03E9tss4YyMtPrW1KDYH4C2+E1RThU+BeFNmgRO6Mm2B+BzxGGxFRlggWQnfJGn76mC1MABHivJbu2m6kS2z1j33+jgowaWaJ1jzODOIzX0BVfcMS2tbaQDKx6O4rDT1D+UCCcrvlj+omUmc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564760259; 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=9D7F9ITpzck5fsEhjBpCtm8o1jPfdXR7LJ0eWEycCww=; b=RPcyjWh/g7T64jQu86sa3Lx1MR/HYixeiaTdx4So5cIggn6zJhlXSNJDQvOO/u3vwVop4wM6lCg+zU+St+BDZkf5K2syjOFoz5yY0LHJJFn0XUfUr8Oz3T/gfs9cTkn2JP/mWQhnuSkStE78bV09cz4GDu3tuVw48fzPUw98NVw= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564760259806722.9783283187323; Fri, 2 Aug 2019 08:37:39 -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 1htZbM-00034d-D6; Fri, 02 Aug 2019 15:36:16 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZbK-00033B-0X for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:36:14 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 412785bc-b53b-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:36:11 +0000 (UTC) X-Inumbo-ID: 412785bc-b53b-11e9-8980-bc764e045a96 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: Fsu0rvVh4CFK2k+AnTkl4T9Mh1d44h5ik1TS1VALKkri0sjn3OHPcIhbwKt1EqNHGIVKWioCzx maCt0gQue60moZdz7ULeOng4VTEjqMnvQ/Sex4leg7O860f3lnMgOO+WLo7uccB5xslLscq6+0 yF4skGTrY4L9su1ndfxxpb17xixEwalPlQbXn9FHu5Iify7nQ/9GFBd6GmAjDgBsSMo4b//T3b BhgbDgixU5RTkBUZgIvArUErFVgGERyvMNFhdg1+LT6a6YZdAZDr+DuOWnT4J68qFggpIINuvi gEg= X-SBRS: 2.7 X-MesageID: 3950108 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,338,1559534400"; d="scan'208";a="3950108" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:39 +0100 Message-ID: <20190802153606.32061-9-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 08/35] libxl: Replace libxl__qmp_initializations by ev_qmp calls 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" Setup a timeout of 10s for all the commands. It used to be about 5s per commands. The order of command is changed, we call 'query-vnc' before 'change-vnc-password', but that should not matter. That makes it easier to call 'change-vnc-password' conditionally. Also 'change' command is replaced by 'change-vnc-password' because 'change' is deprecated. The new command is available in all QEMU versions that also have Xen support. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_dm.c | 211 ++++++++++++++++++++++++++++++++++- tools/libxl/libxl_internal.h | 8 +- tools/libxl/libxl_qmp.c | 169 ---------------------------- 3 files changed, 212 insertions(+), 176 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 5a2e349776..bb5339784e 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2063,11 +2063,13 @@ static int libxl__write_stub_dmargs(libxl__gc *gc, static void dmss_init(libxl__dm_spawn_state *dmss) { libxl__ev_qmp_init(&dmss->qmp); + libxl__ev_time_init(&dmss->timeout); } =20 static void dmss_dispose(libxl__gc *gc, libxl__dm_spawn_state *dmss) { libxl__ev_qmp_dispose(gc, &dmss->qmp); + libxl__ev_time_deregister(gc, &dmss->timeout); } =20 static void spawn_stubdom_pvqemu_cb(libxl__egc *egc, @@ -2462,6 +2464,16 @@ static void device_model_qmp_cb(libxl__egc *egc, lib= xl__ev_qmp *ev, static void device_model_spawn_outcome(libxl__egc *egc, libxl__dm_spawn_state *dmss, int rc); +static void device_model_postconfig_chardev(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc); +static void device_model_postconfig_vnc(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc); +static void device_model_postconfig_vnc_passwd(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc); +static void devise_model_postconfig_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc); +static void device_model_postconfig_done(libxl__egc *egc, + libxl__dm_spawn_state *dmss, int rc); =20 void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss) { @@ -2763,12 +2775,209 @@ static void device_model_spawn_outcome(libxl__egc = *egc, } } =20 + /* Check if spawn failed */ + if (rc) goto out; + if (d_config->b_info.device_model_version =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { - libxl__qmp_initializations(gc, dmss->guest_domid, d_config); + rc =3D libxl__ev_time_register_rel(ao, &dmss->timeout, + devise_model_postconfig_timeout, + LIBXL_QMP_CMD_TIMEOUT * 1000); + if (rc) goto out; + dmss->qmp.ao =3D ao; + dmss->qmp.domid =3D dmss->guest_domid; + dmss->qmp.payload_fd =3D -1; + dmss->qmp.callback =3D device_model_postconfig_chardev; + rc =3D libxl__ev_qmp_send(gc, &dmss->qmp, "query-chardev", NULL); + if (rc) goto out; + return; } =20 out: + device_model_postconfig_done(egc, dmss, rc); /* must be last */ +} + +static void device_model_postconfig_chardev(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc) +{ + EGC_GC; + libxl__dm_spawn_state *dmss =3D CONTAINER_OF(qmp, *dmss, qmp); + const libxl__json_object *item =3D NULL; + const libxl__json_object *o =3D NULL; + int i =3D 0; + const char *label; + const char *filename; + int port; + char *endptr; + const char *dompath; + const char serial[] =3D "serial"; + const size_t seriall =3D sizeof(serial) - 1; + const char pty[] =3D "pty:"; + const size_t ptyl =3D sizeof(pty) - 1; + + if (rc) goto out; + + /* + * query-chardev response: + * [{ 'label': 'str', + * 'filename': 'str', + * 'frontend-open': 'bool' }, ...] + */ + + for (i =3D 0; (item =3D libxl__json_array_get(response, i)); i++) { + o =3D libxl__json_map_get("label", item, JSON_STRING); + if (!o) goto protocol_error; + label =3D libxl__json_object_get_string(o); + + /* Check if the "label" start with "serial". */ + if (!label || strncmp(label, serial, seriall)) + continue; + port =3D strtol(label + seriall, &endptr, 10); + if (*(label + seriall) =3D=3D '\0' || *endptr !=3D '\0') { + LOGD(ERROR, qmp->domid, + "Invalid serial port number: %s", label); + rc =3D ERROR_QEMU_API; + goto out; + } + + o =3D libxl__json_map_get("filename", item, JSON_STRING); + if (!o) goto protocol_error; + filename =3D libxl__json_object_get_string(o); + + /* Check if filename start with "pty:" */ + if (!filename || strncmp(filename, pty, ptyl)) + continue; + + dompath =3D libxl__xs_get_dompath(gc, qmp->domid); + if (!dompath) { + rc =3D ERROR_FAIL; + goto out; + } + rc =3D libxl__xs_printf(gc, XBT_NULL, + GCSPRINTF("%s/serial/%d/tty", dompath, port), + "%s", filename + ptyl); + if (rc) goto out; + } + + qmp->callback =3D device_model_postconfig_vnc; + rc =3D libxl__ev_qmp_send(gc, qmp, "query-vnc", NULL); + if (rc) goto out; + return; + +protocol_error: + rc =3D ERROR_QEMU_API; + LOGD(ERROR, qmp->domid, + "unexpected response to QMP cmd 'query-chardev', received:\n%s", + JSON(response)); +out: + device_model_postconfig_done(egc, dmss, rc); /* must be last */ +} + +static void device_model_postconfig_vnc(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc) +{ + EGC_GC; + libxl__dm_spawn_state *dmss =3D CONTAINER_OF(qmp, *dmss, qmp); + const libxl_vnc_info *vnc =3D libxl__dm_vnc(dmss->guest_config); + const libxl__json_object *o; + libxl__json_object *args =3D NULL; + + if (rc) goto out; + + /* + * query-vnc response: + * { 'enabled': 'bool', '*host': 'str', '*service': 'str' } + */ + + o =3D libxl__json_map_get("enabled", response, JSON_BOOL); + if (!o) goto protocol_error; + if (libxl__json_object_get_bool(o)) { + const char *addr, *port; + const char *dompath; + + o =3D libxl__json_map_get("host", response, JSON_STRING); + if (!o) goto protocol_error; + addr =3D libxl__json_object_get_string(o); + o =3D libxl__json_map_get("service", response, JSON_STRING); + if (!o) goto protocol_error; + port =3D libxl__json_object_get_string(o); + + dompath =3D libxl__xs_get_dompath(gc, qmp->domid); + if (!dompath) { + rc =3D ERROR_FAIL; + goto out; + } + rc =3D libxl__xs_printf(gc, XBT_NULL, + GCSPRINTF("%s/console/vnc-listen", dompath), + "%s", addr); + if (rc) goto out; + rc =3D libxl__xs_printf(gc, XBT_NULL, + GCSPRINTF("%s/console/vnc-port", dompath), + "%s", port); + if (rc) goto out; + } + + if (vnc && vnc->passwd) { + qmp->callback =3D device_model_postconfig_vnc_passwd; + libxl__qmp_param_add_string(gc, &args, "password", vnc->passwd); + rc =3D libxl__ev_qmp_send(gc, qmp, "change-vnc-password", args); + if (rc) goto out; + return; + } + + rc =3D 0; + goto out; + +protocol_error: + rc =3D ERROR_QEMU_API; + LOGD(ERROR, qmp->domid, + "unexpected response to QMP cmd 'query-vnc', received:\n%s", + JSON(response)); +out: + device_model_postconfig_done(egc, dmss, rc); /* must be last */ +} + +static void device_model_postconfig_vnc_passwd(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc) +{ + EGC_GC; + libxl__dm_spawn_state *dmss =3D CONTAINER_OF(qmp, *dmss, qmp); + const libxl_vnc_info *vnc =3D libxl__dm_vnc(dmss->guest_config); + const char *dompath; + + if (rc) goto out; + + dompath =3D libxl__xs_get_dompath(gc, qmp->domid); + if (!dompath) { + rc =3D ERROR_FAIL; + goto out; + } + rc =3D libxl__xs_printf(gc, XBT_NULL, + GCSPRINTF("%s/console/vnc-pass", dompath), + "%s", vnc->passwd); + +out: + device_model_postconfig_done(egc, dmss, rc); /* must be last */ +} + +void devise_model_postconfig_timeout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc) +{ + libxl__dm_spawn_state *dmss =3D CONTAINER_OF(ev, *dmss, timeout); + device_model_postconfig_done(egc, dmss, rc); /* must be last */ +} + + +static void device_model_postconfig_done(libxl__egc *egc, + libxl__dm_spawn_state *dmss, + int rc) +{ + EGC_GC; + + if (rc) + LOGD(ERROR, dmss->guest_domid, + "Post DM startup configs failed, rc=3D%d", rc); dmss_dispose(gc, dmss); dmss->callback(egc, dmss, rc); } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index effc1c5bf9..5e09e602ed 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -100,6 +100,7 @@ #define LIBXL_DEVICE_MODEL_START_TIMEOUT 60 #define LIBXL_DEVICE_MODEL_SAVE_FILE XEN_LIB_DIR "/qemu-save" /* .$domid */ #define LIBXL_DEVICE_MODEL_RESTORE_FILE XEN_LIB_DIR "/qemu-resume" /* .$do= mid */ +#define LIBXL_QMP_CMD_TIMEOUT 10 #define LIBXL_STUBDOM_START_TIMEOUT 30 #define LIBXL_QEMU_BODGE_TIMEOUT 2 #define LIBXL_XENCONSOLE_LIMIT 1048576 @@ -1946,8 +1947,6 @@ _hidden libxl__qmp_handler *libxl__qmp_initialize(lib= xl__gc *gc, _hidden int libxl__qmp_run_command_flexarray(libxl__gc *gc, int domid, const char *cmd, flexarray_t *array); -/* ask to QEMU the serial port information and store it in xenstore. */ -_hidden int libxl__qmp_query_serial(libxl__qmp_handler *qmp); _hidden int libxl__qmp_pci_add(libxl__gc *gc, int d, libxl_device_pci *pci= dev); _hidden int libxl__qmp_pci_del(libxl__gc *gc, int domid, libxl_device_pci *pcidev); @@ -1993,10 +1992,6 @@ _hidden void libxl__qmp_close(libxl__qmp_handler *qm= p); * nothing happen */ _hidden void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid); =20 -/* this helper calls qmp_initialize, query_serial and qmp_close */ -_hidden int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid, - const libxl_domain_config *guest_co= nfig); - /* `data' should contain a byte to send. * When dealing with a non-blocking fd, it returns * ERROR_NOT_READY on EWOULDBLOCK @@ -3953,6 +3948,7 @@ struct libxl__dm_spawn_state { /* mixed - spawn.ao must be initialised by user; rest is private: */ libxl__spawn_state spawn; libxl__ev_qmp qmp; + libxl__ev_time timeout; /* filled in by user, must remain valid: */ uint32_t guest_domid; /* domain being served */ libxl_domain_config *guest_config; diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index f1529925ee..0d6aedcc7d 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -143,121 +143,6 @@ static const int QMP_SOCKET_CONNECT_TIMEOUT =3D 5; * QMP callbacks functions */ =20 -static int store_serial_port_info(libxl__qmp_handler *qmp, - const char *chardev, - int port) -{ - GC_INIT(qmp->ctx); - char *path =3D NULL; - int ret =3D 0; - - if (!(chardev && strncmp("pty:", chardev, 4) =3D=3D 0)) { - return 0; - } - - path =3D libxl__xs_get_dompath(gc, qmp->domid); - path =3D GCSPRINTF("%s/serial/%d/tty", path, port); - - ret =3D libxl__xs_printf(gc, XBT_NULL, path, "%s", chardev + 4); - - GC_FREE; - return ret; -} - -static int register_serials_chardev_callback(libxl__qmp_handler *qmp, - const libxl__json_object *o, - void *unused) -{ - const libxl__json_object *obj =3D NULL; - const libxl__json_object *label =3D NULL; - const char *s =3D NULL; - int i =3D 0; - const char *chardev =3D NULL; - int ret =3D 0; - - for (i =3D 0; (obj =3D libxl__json_array_get(o, i)); i++) { - if (!libxl__json_object_is_map(obj)) - continue; - label =3D libxl__json_map_get("label", obj, JSON_STRING); - s =3D libxl__json_object_get_string(label); - - if (s && strncmp("serial", s, strlen("serial")) =3D=3D 0) { - const libxl__json_object *filename =3D NULL; - char *endptr =3D NULL; - int port_number; - - filename =3D libxl__json_map_get("filename", obj, JSON_STRING); - chardev =3D libxl__json_object_get_string(filename); - - s +=3D strlen("serial"); - port_number =3D strtol(s, &endptr, 10); - if (*s =3D=3D 0 || *endptr !=3D 0) { - LIBXL__LOGD(qmp->ctx, LIBXL__LOG_ERROR, qmp->domid, - "Invalid serial port number: %s", s); - return -1; - } - ret =3D store_serial_port_info(qmp, chardev, port_number); - if (ret) { - LIBXL__LOGD_ERRNO(qmp->ctx, LIBXL__LOG_ERROR, qmp->domid, - "Failed to store serial port information" - " in xenstore"); - return ret; - } - } - }; - - return ret; -} - -static int qmp_write_domain_console_item(libxl__gc *gc, int domid, - const char *item, const char *val= ue) -{ - char *path; - - path =3D libxl__xs_get_dompath(gc, domid); - path =3D GCSPRINTF("%s/console/%s", path, item); - - return libxl__xs_printf(gc, XBT_NULL, path, "%s", value); -} - -static int qmp_register_vnc_callback(libxl__qmp_handler *qmp, - const libxl__json_object *o, - void *unused) -{ - GC_INIT(qmp->ctx); - const libxl__json_object *obj; - const char *addr, *port; - int rc =3D -1; - - if (!libxl__json_object_is_map(o)) { - goto out; - } - - obj =3D libxl__json_map_get("enabled", o, JSON_BOOL); - if (!obj || !libxl__json_object_get_bool(obj)) { - rc =3D 0; - goto out; - } - - obj =3D libxl__json_map_get("host", o, JSON_STRING); - addr =3D libxl__json_object_get_string(obj); - obj =3D libxl__json_map_get("service", o, JSON_STRING); - port =3D libxl__json_object_get_string(obj); - - if (!addr || !port) { - LOGD(ERROR, qmp->domid, "Failed to retrieve VNC connect informatio= n."); - goto out; - } - - rc =3D qmp_write_domain_console_item(gc, qmp->domid, "vnc-listen", add= r); - if (!rc) - rc =3D qmp_write_domain_console_item(gc, qmp->domid, "vnc-port", p= ort); - -out: - GC_FREE; - return rc; -} - static int qmp_capabilities_callback(libxl__qmp_handler *qmp, const libxl__json_object *o, void *un= used) { @@ -851,20 +736,6 @@ void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid) } } =20 -int libxl__qmp_query_serial(libxl__qmp_handler *qmp) -{ - return qmp_synchronous_send(qmp, "query-chardev", NULL, - register_serials_chardev_callback, - NULL, qmp->timeout); -} - -static int qmp_query_vnc(libxl__qmp_handler *qmp) -{ - return qmp_synchronous_send(qmp, "query-vnc", NULL, - qmp_register_vnc_callback, - NULL, qmp->timeout); -} - static int pci_add_callback(libxl__qmp_handler *qmp, const libxl__json_object *response, void *opaq= ue) { @@ -1085,24 +956,6 @@ int libxl__qmp_restore(libxl__gc *gc, int domid, cons= t char *state_file) NULL, NULL); } =20 -static int qmp_change(libxl__gc *gc, libxl__qmp_handler *qmp, - char *device, char *target, char *arg) -{ - libxl__json_object *args =3D NULL; - int rc =3D 0; - - libxl__qmp_param_add_string(gc, &args, "device", device); - libxl__qmp_param_add_string(gc, &args, "target", target); - if (arg) { - libxl__qmp_param_add_string(gc, &args, "arg", arg); - } - - rc =3D qmp_synchronous_send(qmp, "change", args, - NULL, NULL, qmp->timeout); - - return rc; -} - int libxl__qmp_resume(libxl__gc *gc, int domid) { return qmp_run_command(gc, domid, "cont", NULL, NULL, NULL); @@ -1293,28 +1146,6 @@ int libxl_qemu_monitor_command(libxl_ctx *ctx, uint3= 2_t domid, return AO_INPROGRESS; } =20 -int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid, - const libxl_domain_config *guest_config) -{ - const libxl_vnc_info *vnc =3D libxl__dm_vnc(guest_config); - libxl__qmp_handler *qmp =3D NULL; - int ret =3D 0; - - qmp =3D libxl__qmp_initialize(gc, domid); - if (!qmp) - return -1; - ret =3D libxl__qmp_query_serial(qmp); - if (!ret && vnc && vnc->passwd) { - ret =3D qmp_change(gc, qmp, "vnc", "password", vnc->passwd); - qmp_write_domain_console_item(gc, domid, "vnc-pass", vnc->passwd); - } - if (!ret) { - ret =3D qmp_query_vnc(qmp); - } - libxl__qmp_close(qmp); - return ret; -} - =20 /* * Functions using libxl__ev_qmp --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564760243; cv=none; d=zoho.com; s=zohoarc; b=fnfrUyqSATD2pIBIcE9C68wLeQFap/dwa9RpoS2c3b++bC5JWupcJtlTn5ADGGNfqdp1UuDjq8i+deawF50RInqs5Ebc8chReBfdAFd1Fy4JkIxre9BQusg8SvlVhI2GVk3KGUz6JdJSk99CCuceYBSYBi+c9xBMEtncxTUMIKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564760243; 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=k2ENBEVqFSij9FVGteT1BJXCtyuLL+JCM7HBfDZH5dg=; b=C+DlA0wjHtSOrITbaBOPWBrx2bn+Q4ZJnHL7/fAPLSFLpcUZz/kddxQi9nqykWLM+qMzT8d9ZIy3HM3e/6Jci3Fm1Bg1sPA2eJJSIg0j9RPgj4OwSnz4h2PMDQjsq4nmgbuKZyGa8LCbWYWh+ZHkhdRmrTOfQdDfoy1OqMRGVvo= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564760243689896.5740747089283; Fri, 2 Aug 2019 08:37:23 -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 1htZbM-00034R-2U; Fri, 02 Aug 2019 15:36:16 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZbK-00033A-0Y for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:36:14 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 4122ca74-b53b-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:36:11 +0000 (UTC) X-Inumbo-ID: 4122ca74-b53b-11e9-8980-bc764e045a96 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: iIopPvFFWRQPOo+6lnRf89Fm0ADPcMpK8VUCRqSfwdONB4aKP+K1fmUbqXZybzDXAbbuxmJC1W 2RKan1AGhOL5OuWf1Z8dtBs+RFtJ1kciGQtmtn0SGDiJygGQZLFZ+/ers8LzfHrjoBAK7N1qAF gYT52Ipkzsejn4ugPPy+dPg2ttGlHeO5zIANz8dTzRaNgvwkg6lGHzI/ArOZNF6iYAcS6Xkw9H /SfcX++i/m6iD4tdgDG2UtnFf1yjpOgCgGg7hDBFCVFBP5ILjvgbl8AXUpmxzHAf+LWJg98r8/ yng= X-SBRS: 2.7 X-MesageID: 3950109 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,338,1559534400"; d="scan'208";a="3950109" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:40 +0100 Message-ID: <20190802153606.32061-10-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 09/35] libxl: Deprecate libxl__domain_{unpause, resume} 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" These two functions are used from many places in libxl and need to change to be able to accomodate libxl__ev_qmp calls and thus needs to be asynchronous. (There is also libxl__domain_resume_device_model in the mix.) A later patch will introduce a new libxl__domain_resume and libxl__domain_unpause which will make use of libxl__ev_qmp. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_colo_restore.c | 4 ++-- tools/libxl/libxl_colo_save.c | 4 ++-- tools/libxl/libxl_dm.c | 2 +- tools/libxl/libxl_dom_suspend.c | 6 +++--- tools/libxl/libxl_domain.c | 8 ++++---- tools/libxl/libxl_internal.h | 12 ++++++++---- tools/libxl/libxl_remus.c | 2 +- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tools/libxl/libxl_colo_restore.c b/tools/libxl/libxl_colo_rest= ore.c index aaa70552b8..aa365670fb 100644 --- a/tools/libxl/libxl_colo_restore.c +++ b/tools/libxl/libxl_colo_restore.c @@ -124,7 +124,7 @@ static void colo_resume_vm(libxl__egc *egc, return; } } - rc =3D libxl__domain_resume(gc, crs->domid, 0); + rc =3D libxl__domain_resume_deprecated(gc, crs->domid, 0); if (rc) LOGD(ERROR, crs->domid, "cannot resume secondary vm"); =20 @@ -853,7 +853,7 @@ static void colo_unpause_svm(libxl__egc *egc, EGC_GC; =20 /* We have enabled secondary vm's logdirty, so we can unpause it now */ - rc =3D libxl__domain_unpause(gc, domid); + rc =3D libxl__domain_unpause_deprecated(gc, domid); if (rc) { LOGD(ERROR, domid, "cannot unpause secondary vm"); goto out; diff --git a/tools/libxl/libxl_colo_save.c b/tools/libxl/libxl_colo_save.c index 1d261a1639..b47f038f6e 100644 --- a/tools/libxl/libxl_colo_save.c +++ b/tools/libxl/libxl_colo_save.c @@ -470,7 +470,7 @@ static void colo_preresume_cb(libxl__egc *egc, } =20 /* Resumes the domain and the device model */ - if (libxl__domain_resume(gc, dss->domid, /* Fast Suspend */1)) { + if (libxl__domain_resume_deprecated(gc, dss->domid, /* Fast Suspend */= 1)) { LOGD(ERROR, dss->domid, "cannot resume primary vm"); goto out; } @@ -480,7 +480,7 @@ static void colo_preresume_cb(libxl__egc *egc, * no disk migration. */ if (css->paused) { - rc =3D libxl__domain_unpause(gc, dss->domid); + rc =3D libxl__domain_unpause_deprecated(gc, dss->domid); if (rc) { LOGD(ERROR, dss->domid, "cannot unpause primary vm"); goto out; diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index bb5339784e..246c570121 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2404,7 +2404,7 @@ static void stubdom_pvqemu_cb(libxl__egc *egc, goto out; } =20 - rc =3D libxl__domain_unpause(gc, dm_domid); + rc =3D libxl__domain_unpause_deprecated(gc, dm_domid); if (rc) goto out; =20 sdss->xswait.ao =3D ao; diff --git a/tools/libxl/libxl_dom_suspend.c b/tools/libxl/libxl_dom_suspen= d.c index d1af3a6573..2460021e5a 100644 --- a/tools/libxl/libxl_dom_suspend.c +++ b/tools/libxl/libxl_dom_suspend.c @@ -421,7 +421,7 @@ static void domain_suspend_callback_common_done(libxl__= egc *egc, =20 /*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Do= main resume =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D*/ =20 -int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid) +int libxl__domain_resume_device_model_deprecated(libxl__gc *gc, uint32_t d= omid) { const char *path, *state; =20 @@ -449,7 +449,7 @@ int libxl__domain_resume_device_model(libxl__gc *gc, ui= nt32_t domid) return 0; } =20 -int libxl__domain_resume(libxl__gc *gc, uint32_t domid, int suspend_cancel) +int libxl__domain_resume_deprecated(libxl__gc *gc, uint32_t domid, int sus= pend_cancel) { int rc =3D 0; =20 @@ -460,7 +460,7 @@ int libxl__domain_resume(libxl__gc *gc, uint32_t domid,= int suspend_cancel) } =20 if (type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { - rc =3D libxl__domain_resume_device_model(gc, domid); + rc =3D libxl__domain_resume_device_model_deprecated(gc, domid); if (rc) { LOGD(ERROR, domid, "failed to resume device model:%d", rc); goto out; diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index f2d5c86427..80797c5ed2 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -178,7 +178,7 @@ int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid,= int suspend_cancel, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); - int rc =3D libxl__domain_resume(gc, domid, suspend_cancel); + int rc =3D libxl__domain_resume_deprecated(gc, domid, suspend_cancel); libxl__ao_complete(egc, ao, rc); return AO_INPROGRESS; } @@ -593,7 +593,7 @@ int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t dom= id, return AO_INPROGRESS; } =20 -int libxl__domain_unpause(libxl__gc *gc, libxl_domid domid) +int libxl__domain_unpause_deprecated(libxl__gc *gc, libxl_domid domid) { int r, rc; =20 @@ -604,7 +604,7 @@ int libxl__domain_unpause(libxl__gc *gc, libxl_domid do= mid) } =20 if (type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { - rc =3D libxl__domain_resume_device_model(gc, domid); + rc =3D libxl__domain_resume_device_model_deprecated(gc, domid); if (rc < 0) { LOGD(ERROR, domid, "Failed to unpause device model for domain: %d", rc); @@ -628,7 +628,7 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid, AO_CREATE(ctx, domid, ao_how); int rc =3D 0; =20 - rc =3D libxl__domain_unpause(gc, domid); + rc =3D libxl__domain_unpause_deprecated(gc, domid); if (rc) goto out; =20 libxl__ao_complete(egc, ao, rc); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 5e09e602ed..da3631d853 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1314,7 +1314,8 @@ _hidden int libxl__domain_rename(libxl__gc *gc, uint3= 2_t domid, const char *old_name, const char *new_nam= e, xs_transaction_t trans); =20 -_hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domi= d); +/* Deprecated, use libxl__dm_resume instead. */ +_hidden int libxl__domain_resume_device_model_deprecated(libxl__gc *gc, ui= nt32_t domid); =20 _hidden const char *libxl__userdata_path(libxl__gc *gc, uint32_t domid, const char *userdata_userid, @@ -1331,8 +1332,12 @@ _hidden int libxl__userdata_store(libxl__gc *gc, uin= t32_t domid, const char *userdata_userid, const uint8_t *data, int datalen); =20 -_hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid, - int suspend_cancel); +/* Deprecated, use libxl__domain_resume instead */ +_hidden int libxl__domain_resume_deprecated(libxl__gc *gc, uint32_t domid, + int suspend_cancel); +/* Deprecated, use libxl__domain_unpause instead */ +_hidden int libxl__domain_unpause_deprecated(libxl__gc *, + libxl_domid domid); =20 /* returns 0 or 1, or a libxl error code */ _hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domi= d); @@ -4103,7 +4108,6 @@ _hidden void libxl__remus_teardown(libxl__egc *egc, int rc); _hidden void libxl__remus_restore_setup(libxl__egc *egc, libxl__domain_create_state *dcs); -_hidden int libxl__domain_unpause(libxl__gc *, libxl_domid domid); =20 =20 /* diff --git a/tools/libxl/libxl_remus.c b/tools/libxl/libxl_remus.c index 29a47838c8..6338a1bae5 100644 --- a/tools/libxl/libxl_remus.c +++ b/tools/libxl/libxl_remus.c @@ -267,7 +267,7 @@ static void remus_devices_preresume_cb(libxl__egc *egc, goto out; =20 /* Resumes the domain and the device model */ - rc =3D libxl__domain_resume(gc, dss->domid, /* Fast Suspend */1); + rc =3D libxl__domain_resume_deprecated(gc, dss->domid, /* Fast Suspend= */1); if (rc) goto out; =20 --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761538; cv=none; d=zoho.com; s=zohoarc; b=JSL4jIjmT1mU7YffH3A4A0qnm4KqdLMwYe8qN/lK5ynKSnM0meKZYe3EjL2BBc1bmN1Ov1yQW6LiiSNYV2xWOw2yPc/xknPuPkJeT5hBhXojl/uLWfHibQBHhC5KrZFq2lwDCmeV7PpCEH8EgENELgH+ydE9Inx3gt2HjaiVI68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761538; 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=smuAKxGqzweIzLTPkOJT9yHw7BjuqFMrp93Jjemg4gg=; b=M6ZCd4BCfoFNeNkcUzX0oxv2qcy1+TNipCI18lqX7BXrOr0vLohti+xHDTa7wNdfIaoSVKXNxycjnOWvodDjOMPNRXDfl+yjZ6T8YyURv5bc7wzZVc30L24v8SJZCXqjgbWqGQP08DsyajsmR0N2sysAGEIbwQLp/5YK7ijXdPw= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761538402484.18902740940734; Fri, 2 Aug 2019 08:58:58 -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 1htZwo-0006MN-C2; Fri, 02 Aug 2019 15:58:26 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwn-0006Js-1u for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:25 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5ab57478-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:22 +0000 (UTC) X-Inumbo-ID: 5ab57478-b53e-11e9-8980-bc764e045a96 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: ryG2UEzmzU47op5zZH8OObEgkLtSM4TafK+f4q9sbuw4vlyM/jt9Wn7Toj3vw+uNvFGjcp1CqH zQrrRtyCWtmebiqmS06a1wgz8aX1dfUfqoOzgBn5HmgSTs5CBBdmowG+iUQCgVI6YJ6JtBsR8N 0dyOYMQaFPG2cHv2dxKSoJYU9BvUl3xH+goYgP8wqK4smXQWMzaFlWpTBJQ4lZXURz6JteZU4F aeTJnGv/32q+dNFVt9ZUg6rYJklfgEW/iHK1BRfR0p34Ys8fBu53MUdf5QfLsy8nca+R9tgjRF 7AU= X-SBRS: 2.7 X-MesageID: 3951240 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,338,1559534400"; d="scan'208";a="3951240" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:41 +0100 Message-ID: <20190802153606.32061-11-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 10/35] libxl: Re-introduce libxl__domain_resume 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" libxl__domain_resume is a rework libxl__domain_resume_deprecated. It makes uses of ev_xswatch and ev_qmp, to replace synchronous QMP calls and libxl__wait_for_device_model_deprecated call. This patch also introduce libxl__dm_resume which is a sub-operation of both libxl__domain_resume and libxl__domain_unpause and can be used instead of libxl__domain_resume_device_model_deprecated. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_dom_suspend.c | 192 ++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 27 +++++ 2 files changed, 219 insertions(+) diff --git a/tools/libxl/libxl_dom_suspend.c b/tools/libxl/libxl_dom_suspen= d.c index 2460021e5a..9bb2d00bec 100644 --- a/tools/libxl/libxl_dom_suspend.c +++ b/tools/libxl/libxl_dom_suspend.c @@ -481,6 +481,198 @@ int libxl__domain_resume_deprecated(libxl__gc *gc, ui= nt32_t domid, int suspend_c return rc; } =20 +static void dm_resume_init(libxl__dm_resume_state *dmrs) +{ + libxl__ev_qmp_init(&dmrs->qmp); + libxl__ev_time_init(&dmrs->time); + libxl__ev_xswatch_init(&dmrs->watch); +} + +static void dm_resume_dispose(libxl__gc *gc, + libxl__dm_resume_state *dmrs) +{ + libxl__ev_qmp_dispose(gc, &dmrs->qmp); + libxl__ev_time_deregister(gc, &dmrs->time); + libxl__ev_xswatch_deregister(gc, &dmrs->watch); +} + +static void dm_resume_xswatch_cb(libxl__egc *egc, + libxl__ev_xswatch *, const char *watch_path, const char *); +static void dm_resume_qmp_done(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *, int rc); +static void dm_resume_timeout(libxl__egc *egc, + libxl__ev_time *, const struct timeval *, int rc); +static void dm_resume_done(libxl__egc *egc, + libxl__dm_resume_state *dmrs, int rc); + +void libxl__dm_resume(libxl__egc *egc, + libxl__dm_resume_state *dmrs) +{ + STATE_AO_GC(dmrs->ao); + int rc =3D 0; + + /* Convenience aliases */ + libxl_domid domid =3D dmrs->domid; + libxl__ev_qmp *qmp =3D &dmrs->qmp; + + dm_resume_init(dmrs); + + rc =3D libxl__ev_time_register_rel(dmrs->ao, + &dmrs->time, + dm_resume_timeout, + LIBXL_DEVICE_MODEL_START_TIMEOUT); + if (rc) goto out; + + switch (libxl__device_model_version_running(gc, domid)) { + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: { + uint32_t dm_domid =3D libxl_get_stubdom_id(CTX, domid); + const char *path, *state; + + path =3D DEVICE_MODEL_XS_PATH(gc, dm_domid, domid, "/state"); + rc =3D libxl__xs_read_checked(gc, XBT_NULL, path, &state); + if (rc) goto out; + if (!state || strcmp(state, "paused")) { + /* already running */ + rc =3D 0; + goto out; + } + + rc =3D libxl__qemu_traditional_cmd(gc, domid, "continue"); + if (rc) goto out; + rc =3D libxl__ev_xswatch_register(gc, &dmrs->watch, + dm_resume_xswatch_cb, + path); + if (rc) goto out; + break; + } + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: + qmp->ao =3D dmrs->ao; + qmp->domid =3D domid; + qmp->callback =3D dm_resume_qmp_done; + qmp->payload_fd =3D -1; + rc =3D libxl__ev_qmp_send(gc, qmp, "cont", NULL); + if (rc) goto out; + break; + default: + rc =3D ERROR_INVAL; + goto out; + } + + return; + +out: + dm_resume_done(egc, dmrs, rc); +} + +static void dm_resume_xswatch_cb(libxl__egc *egc, + libxl__ev_xswatch *xsw, + const char *watch_path, + const char *event_path) +{ + EGC_GC; + libxl__dm_resume_state *dmrs =3D CONTAINER_OF(xsw, *dmrs, watch); + int rc; + const char *value; + + rc =3D libxl__xs_read_checked(gc, XBT_NULL, watch_path, &value); + if (rc) goto out; + + if (!value || strcmp(value, "running")) + return; + + rc =3D 0; +out: + dm_resume_done(egc, dmrs, rc); +} + +static void dm_resume_qmp_done(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + libxl__dm_resume_state *dmrs =3D CONTAINER_OF(qmp, *dmrs, qmp); + dm_resume_done(egc, dmrs, rc); +} + +static void dm_resume_timeout(libxl__egc *egc, + libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc) +{ + libxl__dm_resume_state *dmrs =3D CONTAINER_OF(ev, *dmrs, time); + dm_resume_done(egc, dmrs, rc); +} + +static void dm_resume_done(libxl__egc *egc, + libxl__dm_resume_state *dmrs, + int rc) +{ + EGC_GC; + + if (rc) { + LOGD(ERROR, dmrs->domid, + "Failed to resume device model: rc=3D%d", rc); + } + + dm_resume_dispose(gc, dmrs); + dmrs->dm_resumed_callback(egc, dmrs, rc); +} + + +static void domain_resume_done(libxl__egc *egc, + libxl__dm_resume_state *dmrs, int rc); + +void libxl__domain_resume(libxl__egc *egc, + libxl__dm_resume_state *dmrs, + bool suspend_cancel) +{ + STATE_AO_GC(dmrs->ao); + int rc =3D 0; + libxl_domain_type type =3D libxl__domain_type(gc, dmrs->domid); + + if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) { + rc =3D ERROR_FAIL; + goto out; + } + + if (type !=3D LIBXL_DOMAIN_TYPE_HVM) { + rc =3D 0; + goto out; + } + + dmrs->suspend_cancel =3D suspend_cancel; + dmrs->dm_resumed_callback =3D domain_resume_done; + libxl__dm_resume(egc, dmrs); /* must be last */ + return; + +out: + domain_resume_done(egc, dmrs, rc); +} + +static void domain_resume_done(libxl__egc *egc, + libxl__dm_resume_state *dmrs, int rc) +{ + EGC_GC; + + /* Convenience aliases */ + libxl_domid domid =3D dmrs->domid; + + if (rc) goto out; + + if (xc_domain_resume(CTX->xch, domid, dmrs->suspend_cancel)) { + LOGED(ERROR, domid, "xc_domain_resume failed"); + rc =3D ERROR_FAIL; + goto out; + } + + if (!xs_resume_domain(CTX->xsh, domid)) { + LOGED(ERROR, domid, "xs_resume_domain failed"); + rc =3D ERROR_FAIL; + } +out: + dmrs->callback(egc, dmrs, rc); +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index da3631d853..bdc9677527 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -197,6 +197,7 @@ typedef struct libxl__device_type libxl__device_type; typedef struct libxl__json_object libxl__json_object; typedef struct libxl__carefd libxl__carefd; typedef struct libxl__ev_lock libxl__ev_lock; +typedef struct libxl__dm_resume_state libxl__dm_resume_state; =20 typedef struct libxl__domain_create_state libxl__domain_create_state; typedef void libxl__domain_create_cb(struct libxl__egc *egc, @@ -1339,6 +1340,32 @@ _hidden int libxl__domain_resume_deprecated(libxl__g= c *gc, uint32_t domid, _hidden int libxl__domain_unpause_deprecated(libxl__gc *, libxl_domid domid); =20 +/* Call libxl__dm_resume_init() and fill the first few fields, + * then call one of libxl__domain_resume / libxl__domain_unpause + * or directly libxl__dm_resume if only the device model needs to be + * "resumed". */ +struct libxl__dm_resume_state { + /* caller must fill these in, and they must all remain valid */ + libxl__ao *ao; + libxl_domid domid; + void (*callback)(libxl__egc *, libxl__dm_resume_state *, int rc); + + /* private to libxl__domain_resume */ + void (*dm_resumed_callback)(libxl__egc *, + libxl__dm_resume_state *, int rc); + bool suspend_cancel; + + /* private to libxl__dm_resume */ + libxl__ev_qmp qmp; + libxl__ev_time time; + libxl__ev_xswatch watch; +}; +_hidden void libxl__dm_resume(libxl__egc *egc, + libxl__dm_resume_state *dmrs); +_hidden void libxl__domain_resume(libxl__egc *egc, + libxl__dm_resume_state *dmrs, + bool suspend_cancel); + /* returns 0 or 1, or a libxl error code */ _hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domi= d); =20 --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761556; cv=none; d=zoho.com; s=zohoarc; b=cm6kNjz+mkvnkz/3ptuhpIDN50aQmkihPIE6XmvuoWfTTLJGomsnj4kqVy3a9MlCeus8EPhbnTr0l7xwiV6JubtZFduCy0/UDX1QiUS4AtRmfqJ0WD5zNPOW3eVFDignaFlUyxIg6VBfTpAuTR7wXOX2zOpJfA1gfwOJY2JqCt4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761556; 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=vH9/+KjoAAJf8E5PIW06uyIJBF7Z6OByz0j2HP1JKXI=; b=TjI2c7fy9ltzzEbHM09mNKUw5xVEvFBrFHLe0SCvXRM0e3CjrNh3HJG01FjlMzpDKmgm9ypaLcI+HzFRzN9zJ8iy8Mpzdu2CYI/VpDp5oZ4oxZtJAYLGoVpuTYBTCkhha7PCwGRNmk3ETJbfkLyhIAwQ3suEBigMWEPU1GbeALk= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761556795650.3257427072593; Fri, 2 Aug 2019 08:59:16 -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 1htZwf-00066e-VS; Fri, 02 Aug 2019 15:58:17 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwe-00065E-FK for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:16 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 56240c68-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:15 +0000 (UTC) X-Inumbo-ID: 56240c68-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: FpxYhue0rTmDZ0Yc/0mvIIlQSJeM63NhVo4S7+ZLmf8MB3AkKsHqb931Qi3xncWFlHZIE0oN5/ yhsGvCIAS8Vd50Lm461LfyVYpLdDpF0tKCuMw0WVnq6cs76Fam1eVIFGHWW8Y/joNA6iw+qOcx wvK81Rdk4YbiePSLAJaLerqsxg23v9LvoP79FWyqoOrxqiVIHrMnCWb31H86XzacFfF1zeORTb 0t0cMXURFjZhN8XBCJLqTeNhF10nLJ477RVIECFTHhwWz7ZcRYWeuvjO+l8PBZD5P+xR0meKTb LxU= X-SBRS: 2.7 X-MesageID: 3787824 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3787824" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:42 +0100 Message-ID: <20190802153606.32061-12-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 11/35] libxl_domain: Convert libxl_domain_resume to use libxl__domain_resume 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" Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_domain.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 80797c5ed2..d78ffa6b60 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -174,15 +174,32 @@ int libxl_domain_rename(libxl_ctx *ctx, uint32_t domi= d, return rc; } =20 +static void domain_resume_done(libxl__egc *egc, + libxl__dm_resume_state *, + int rc); + int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); - int rc =3D libxl__domain_resume_deprecated(gc, domid, suspend_cancel); - libxl__ao_complete(egc, ao, rc); + libxl__dm_resume_state *dmrs; + + GCNEW(dmrs); + dmrs->ao =3D ao; + dmrs->domid =3D domid; + dmrs->callback =3D domain_resume_done; + libxl__domain_resume(egc, dmrs, suspend_cancel); return AO_INPROGRESS; } =20 +static void domain_resume_done(libxl__egc *egc, + libxl__dm_resume_state *dmrs, + int rc) +{ + STATE_AO_GC(dmrs->ao); + libxl__ao_complete(egc, ao, rc); +} + /* * Preserves a domain but rewrites xenstore etc to make it unique so * that the domain can be restarted. --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761537; cv=none; d=zoho.com; s=zohoarc; b=JO9YOxYRNxfmm++fNHG4OeM63Gor70ZiqEir0xwzBOwZVSc+2aNf2gCPH3fdDT6doQvfbgji8WwO9jLMiypfN+RQtTL+Ak+0RqSu8HXF+73Ia1TyIdopV3GpRPY9MZ1SM90YJ4CuTKEJf+Pup6MDVyPeR+A0z9Mw5/dyF/r9SZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761537; 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=LisL9z6fc6ElzNmyz/PCCwjDtt0Fg2vt5nStgKRqhRg=; b=mprZSMIXqNmMyXvVlBjEjeonL+g3Jit9YfRroDk7qPNhHumLn5r5obQ+RVn7As0SRjhGV2J9sIyvMYFaNEvQY7IwqnejJxZzIIwXRi1DY7JCRUUeqy8sJ4lUIlnwtmXKU3dNyqyWBoByvQhcRapo30tfA/9yRU3UUIOmDJFQl1A= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761537304328.29911580028863; Fri, 2 Aug 2019 08:58:57 -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 1htZwK-0005o0-Ds; Fri, 02 Aug 2019 15:57:56 +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 1htZwJ-0005nY-8c for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:57:55 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4784b75c-b53e-11e9-88c6-d7550dcbd3a0; Fri, 02 Aug 2019 15:57:50 +0000 (UTC) X-Inumbo-ID: 4784b75c-b53e-11e9-88c6-d7550dcbd3a0 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: YTNn9mWiPmVoaR/3r5d6oXyOiwVlzUyRxDWdeKlIvzrfDwk8fxwUDmJWWZQYG1wTAKQaDss+eb pszbjjZwTfLWGn3bQDQccuxjPGKIOovB2JoqHX95g4evUHOET2da/3pdld9wsmuk2DRfbNRdhp w1oH41TTVuLm4pXeSo7WFz+W0Qzz4nd7KfBotQA1dejpRJCnheuaeFnuATR4x0lTiAWkINZ5YQ 4ETDKzpzPLcttotJ+FKH0wHrEXrBfT3YK2eA83GbsADPo6aWD2sFt5ZyM7rS4mo2gz/eDBkrLz E1c= X-SBRS: 2.7 X-MesageID: 3951211 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,338,1559534400"; d="scan'208";a="3951211" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:43 +0100 Message-ID: <20190802153606.32061-13-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 12/35] libxl: Re-introduce libxl__domain_unpause 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" libxl__domain_unpause is a reimplementation of libxl__domain_unpause_deprecated with asynchronous operation. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_domain.c | 52 ++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 5 +++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index d78ffa6b60..52a8bd7895 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -639,6 +639,58 @@ int libxl__domain_unpause_deprecated(libxl__gc *gc, li= bxl_domid domid) return rc; } =20 +static void domain_unpause_done(libxl__egc *egc, + libxl__dm_resume_state *, + int rc); + +void libxl__domain_unpause(libxl__egc *egc, + libxl__dm_resume_state *dmrs) +{ + STATE_AO_GC(dmrs->ao); + int rc =3D 0; + + /* Convenience aliases */ + libxl_domid domid =3D dmrs->domid; + + libxl_domain_type type =3D libxl__domain_type(gc, domid); + if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) { + rc =3D ERROR_FAIL; + goto out; + } + + if (type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { + dmrs->dm_resumed_callback =3D domain_unpause_done; + libxl__dm_resume(egc, dmrs); /* must be last */ + return; + } + rc =3D 0; +out: + domain_unpause_done(egc, dmrs, rc); +} + +static void domain_unpause_done(libxl__egc *egc, + libxl__dm_resume_state *dmrs, + int rc) +{ + EGC_GC; + int r; + + /* Convenience aliases */ + libxl_domid domid =3D dmrs->domid; + + if (rc) goto out; + + r =3D xc_domain_unpause(CTX->xch, domid); + if (r < 0) { + LOGED(ERROR, domid, "Unpausing domain"); + rc =3D ERROR_FAIL; + goto out; + } + rc =3D 0; +out: + dmrs->callback(egc, dmrs, rc); +} + int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid, const libxl_asyncop_how *ao_how) { diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index bdc9677527..1cfe3cf83f 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1350,9 +1350,10 @@ struct libxl__dm_resume_state { libxl_domid domid; void (*callback)(libxl__egc *, libxl__dm_resume_state *, int rc); =20 - /* private to libxl__domain_resume */ + /* private to libxl__domain_resume and libxl__domain_unpause */ void (*dm_resumed_callback)(libxl__egc *, libxl__dm_resume_state *, int rc); + /* private to libxl__domain_resume */ bool suspend_cancel; =20 /* private to libxl__dm_resume */ @@ -1365,6 +1366,8 @@ _hidden void libxl__dm_resume(libxl__egc *egc, _hidden void libxl__domain_resume(libxl__egc *egc, libxl__dm_resume_state *dmrs, bool suspend_cancel); +_hidden void libxl__domain_unpause(libxl__egc *, + libxl__dm_resume_state *dmrs); =20 /* returns 0 or 1, or a libxl error code */ _hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domi= d); --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761557; cv=none; d=zoho.com; s=zohoarc; b=WtuWlWZ8rcDNR4hBVqJWccxguG4GAHA1NqdCALqUNY/EG1NI8cReiebNC/kuUh7htMrXjhgZk9XZ7nWDeURoyq51rZFE5+kfGeofxYp4GFw0yj3Qcw2ykziTmHyAU1/JUm/cQffOa7p5GNAdYIVgCdCZICQoadWgPanAu4AHxR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761557; 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=RcwHCaHEg7RE+qJigepDhE51sBbP4lzai3GULhw6Ncw=; b=O/qLFNayu9+cjM7CM5PuUGW5olhkLVDfoKeXK+8uURv8Mr4jJZQRzYGDwcZmBOc9Z6QPJHnWgiYBPVig3tJOUGvisCS2CLcbkIGfHoTaUjrQAdaYMgJKrR1OyLhNKbFJKeg5KjaigbSyvnCuVer7dhzYTIfizPnaZezBIppRZRw= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761557204330.45570339474295; Fri, 2 Aug 2019 08:59:17 -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 1htZx5-0006sI-Ra; Fri, 02 Aug 2019 15:58:43 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZx5-0006qy-77 for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:43 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 660fee57-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:41 +0000 (UTC) X-Inumbo-ID: 660fee57-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Mys2SgZAiQ9+r4VKCFV0wLPXOxfBN32PVeRIpoIlAUqt7QX7+WksXIWn9KgFlRZ55VdMJG7LeV lfQdShPfbSMCFd9obnvCzzg0HobA9Jokwn88hnWfg4Fv5IURQSLpJhBiVzksd/ScvGW1zZn6AG RF6nO52ifIVDbffKxbYToh/CeyGiJ4yJuD/f8cfxJ1YqG0kW1zNZ2vKJ0YSHsYUHh2kZALkecp V89B04qqY3MKyLMMsh8kE74HxV4zlAD8O4jXB8pYoGc1FTrxYia6F9sp3vcLUZrJH5+nWjpHu8 DG8= X-SBRS: 2.7 X-MesageID: 3797676 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3797676" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:44 +0100 Message-ID: <20190802153606.32061-14-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 13/35] libxl_dm: Update libxl__spawn_stub_dm to use libxl__domain_unpause 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" Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_dm.c | 22 +++++++++++++++++++++- tools/libxl/libxl_internal.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 246c570121..c00356a2f1 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2082,6 +2082,9 @@ static void spawn_stub_launch_dm(libxl__egc *egc, static void stubdom_pvqemu_cb(libxl__egc *egc, libxl__multidev *aodevs, int rc); +static void stubdom_pvqemu_unpaused(libxl__egc *egc, + libxl__dm_resume_state *dmrs, + int rc); =20 static void stubdom_xswait_cb(libxl__egc *egc, libxl__xswait_state *xswait, int rc, const char *p); @@ -2404,7 +2407,24 @@ static void stubdom_pvqemu_cb(libxl__egc *egc, goto out; } =20 - rc =3D libxl__domain_unpause_deprecated(gc, dm_domid); + sdss->pvqemu.dmrs.ao =3D ao; + sdss->pvqemu.dmrs.domid =3D dm_domid; + sdss->pvqemu.dmrs.callback =3D stubdom_pvqemu_unpaused; + libxl__domain_unpause(egc, &sdss->pvqemu.dmrs); /* must be last */ + return; +out: + stubdom_pvqemu_unpaused(egc, &sdss->pvqemu.dmrs, rc); +} + +static void stubdom_pvqemu_unpaused(libxl__egc *egc, + libxl__dm_resume_state *dmrs, + int rc) +{ + libxl__stub_dm_spawn_state *sdss =3D + CONTAINER_OF(dmrs, *sdss, pvqemu.dmrs); + STATE_AO_GC(sdss->dm.spawn.ao); + uint32_t dm_domid =3D sdss->pvqemu.guest_domid; + if (rc) goto out; =20 sdss->xswait.ao =3D ao; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 1cfe3cf83f..7cabfd61b7 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3984,6 +3984,7 @@ struct libxl__dm_spawn_state { libxl__spawn_state spawn; libxl__ev_qmp qmp; libxl__ev_time timeout; + libxl__dm_resume_state dmrs; /* filled in by user, must remain valid: */ uint32_t guest_domid; /* domain being served */ libxl_domain_config *guest_config; --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761537; cv=none; d=zoho.com; s=zohoarc; b=OYLfHPxTRX/gZ5kmDa2WXLho32WSYuHl13PufJakObwtS91z1wX/K7+IDM8Js71LJlLRzRzmEiN05OqJGVQ2Rj1v+s8MB9kR3TkG7F3leYFNqbDVpNZ2fHlKwer0OT8Qwhbjcr8tpvBGBtlVLxRD5Tez7er3TLDiabWt5BjVgsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761537; 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=XpKQUDmWX00browjlPF+lAv+G25hc0yc3VnGYArhBpY=; b=T4g5NaW3zB1ElAtgs9fv+xcriIGj+s3dx+xSASjTy5dJ41y6IZ4lLStUSVWecyh1vkVatTlk6Ljv1jwf8h4lTt2AGAZSjTFxAMkweKrHmkB41Nocwu/05sZdAxWyG++kZ0qwh6zh6MVy7AUEAKGPcCt+IiN08JuaA1T2XJtLLrE= ARC-Authentication-Results: i=1; mx.zoho.com; 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 156476153731423.915977889198075; Fri, 2 Aug 2019 08:58:57 -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 1htZwO-0005qC-4B; Fri, 02 Aug 2019 15:58:00 +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 1htZwM-0005pU-P2 for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:57:58 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 49ce068a-b53e-11e9-830f-1be5d4030396; Fri, 02 Aug 2019 15:57:54 +0000 (UTC) X-Inumbo-ID: 49ce068a-b53e-11e9-830f-1be5d4030396 Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: s+GR/ZGdbxONnQGtnwqHbjCzTSYLXHfRiRY2TOgIgyX9zDIRKeWEaqmsBQzkUyPedCLPStvY7K pCR6oKVF3U0C1Id48DgCN2SAh5BIj8gK3LEIg4LUf/HgfpXu6ZcfTpfFQzIqLp9WCmqt911tVo sMZvDAIlvCYkJJ2q+UW/LDWvltEo6yNjl9S37PPboBq3y1GH2rIpsE0oQuudbGKbsY7vtwpZLq Zsf58TG7tVy43EgPxC3ntCv4U/Sls7yogKeg22it+1eP4wmM4Jxji/bcRv/mrWtbgEXOi2arza Hj8= X-SBRS: 2.7 X-MesageID: 3826756 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3826756" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:45 +0100 Message-ID: <20190802153606.32061-15-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 14/35] libxl_domain: Convert libxl_domain_unpause to use libxl__domain_unpause 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" Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_domain.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 52a8bd7895..f3c39fa86f 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -691,20 +691,31 @@ static void domain_unpause_done(libxl__egc *egc, dmrs->callback(egc, dmrs, rc); } =20 +static void domain_unpause_ao_done(libxl__egc *egc, + libxl__dm_resume_state *, + int rc); + int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); - int rc =3D 0; - - rc =3D libxl__domain_unpause_deprecated(gc, domid); - if (rc) goto out; + libxl__dm_resume_state *dmrs; =20 - libxl__ao_complete(egc, ao, rc); + GCNEW(dmrs); + dmrs->ao =3D ao; + dmrs->domid =3D domid; + dmrs->callback =3D domain_unpause_ao_done; + libxl__domain_unpause(egc, dmrs); /* must be last */ return AO_INPROGRESS; +} =20 - out: - return AO_CREATE_FAIL(rc); +static void domain_unpause_ao_done(libxl__egc *egc, + libxl__dm_resume_state *dmrs, + int rc) +{ + STATE_AO_GC(dmrs->ao); + + libxl__ao_complete(egc, ao, rc); } =20 int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid) --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761554; cv=none; d=zoho.com; s=zohoarc; b=a9D+9EUPSS9UM+11PV2eGxgnGF031Cu+lrIdb/PcTklt2NWXhut3bRNO1weMhUn8zzvcZ4PLjebhvak+VumwGT18Q0XgoANP61U+VNA/t6bMH1BQkbtjqxk84F2cZmC6xxF8pHGFQgOTRV0yxu1vvLkFkqTqvlcTSqxv3SV7R2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761554; 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=zNinlIq9Prpfywe7wE0XRo0XC41HNRmP19+BpTcWyOM=; b=VV+JFL9uITX/jQcZXjE0w5aMxPf+bf8TovwmI2vxW40BF1dd0eZanyhepnmHHGVuvkuk4BvoKoafBhKJwqisuQQwIhdgCiYIqyf1BiC5HGkyuuo9zY9DqUBLb6m5bn8EkDd3D+kYn6h+XWC5fK+EJ1VU5mqqzbF9KKwz130PQyk= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761554000138.43761448000078; Fri, 2 Aug 2019 08:59:14 -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 1htZwf-00066F-JO; Fri, 02 Aug 2019 15:58:17 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwe-00064t-4H for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:16 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5602e1f0-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:14 +0000 (UTC) X-Inumbo-ID: 5602e1f0-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: aa0TOMMODD5cqOZBZlWPgeqE5h5GW4jqGv6t9lzVLyq1ugv1C+lBSMsVz5Z7np+2qE7D7olauz yqQ+KI4Q75LvVF9XYx344tAy/5xBX31pqEOPmjB+tuDJC0bg+lVmD7vJ3LTvP7MX4QsfB9ifWd LFoLMzX3y7o7kI7SqBU547wUs8TvS1lj6aQMBchZHFox0v04njuImmTWrvddaR9uMzS311vQpq ScDGCcGkbfScedAGKS1eNF4jVNBwIZ9cBegJ8XFZqkT9wdhHOkKb7smsfgLBE9DMqGCyFdx22q +sI= X-SBRS: 2.7 X-MesageID: 3931682 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3931682" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:46 +0100 Message-ID: <20190802153606.32061-16-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 15/35] libxl: Inline do_usbdev_add into libxl__device_usbdev_add 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" Having the function do_usbdev_add makes it harder to add asynchronous calls into it. Move its body back into libxl__device_usbdev_add and adjust the latter as there are no reason to have a separated function. No functional changes. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_usb.c | 121 ++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 68 deletions(-) diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c index 3d69379c20..43c8ad3ee3 100644 --- a/tools/libxl/libxl_usb.c +++ b/tools/libxl/libxl_usb.c @@ -1519,72 +1519,6 @@ static int usbback_dev_assign(libxl__gc *gc, const c= har *busid) return rc; } =20 -static int do_usbdev_add(libxl__gc *gc, uint32_t domid, - libxl_device_usbdev *usbdev, - bool update_json) -{ - int rc; - char *busid; - libxl_device_usbctrl usbctrl; - - libxl_device_usbctrl_init(&usbctrl); - rc =3D libxl_devid_to_device_usbctrl(CTX, domid, usbdev->ctrl, &usbctr= l); - if (rc) goto out; - - switch (usbctrl.type) { - case LIBXL_USBCTRL_TYPE_PV: - busid =3D usbdev_busaddr_to_busid(gc, usbdev->u.hostdev.hostbus, - usbdev->u.hostdev.hostaddr); - if (!busid) { - rc =3D ERROR_FAIL; - goto out; - } - - rc =3D libxl__device_usbdev_add_xenstore(gc, domid, usbdev, - LIBXL_USBCTRL_TYPE_PV, - update_json); - if (rc) goto out; - - rc =3D usbback_dev_assign(gc, busid); - if (rc) { - libxl__device_usbdev_remove_xenstore(gc, domid, usbdev, - LIBXL_USBCTRL_TYPE_PV); - goto out; - } - break; - case LIBXL_USBCTRL_TYPE_QUSB: - rc =3D libxl__device_usbdev_add_xenstore(gc, domid, usbdev, - LIBXL_USBCTRL_TYPE_QUSB, - update_json); - if (rc) goto out; - - break; - case LIBXL_USBCTRL_TYPE_DEVICEMODEL: - rc =3D libxl__device_usbdev_add_xenstore(gc, domid, usbdev, - LIBXL_USBCTRL_TYPE_DEVICEMO= DEL, - update_json); - if (rc) goto out; - - rc =3D libxl__device_usbdev_add_hvm(gc, domid, usbdev); - if (rc) { - libxl__device_usbdev_remove_xenstore(gc, domid, usbdev, - LIBXL_USBCTRL_TYPE_DEVICEMODE= L); - goto out; - } - break; - default: - LOGD(ERROR, domid, "Unsupported usb controller type"); - rc =3D ERROR_FAIL; - goto out; - } - - rc =3D 0; - -out: - libxl_device_usbctrl_dispose(&usbctrl); - return rc; -} - /* AO operation to add a usb device. * * Generally, it does: @@ -1610,6 +1544,7 @@ static void libxl__device_usbdev_add(libxl__egc *egc,= uint32_t domid, libxl_device_usbdev *assigned; int num_assigned; libxl_device_usbctrl usbctrl; + char *busid; =20 libxl_device_usbctrl_init(&usbctrl); =20 @@ -1628,6 +1563,7 @@ static void libxl__device_usbdev_add(libxl__egc *egc,= uint32_t domid, rc =3D ERROR_INVAL; goto out; } + libxl_device_usbctrl_dispose(&usbctrl); } =20 /* check usb device is assignable type */ @@ -1657,14 +1593,63 @@ static void libxl__device_usbdev_add(libxl__egc *eg= c, uint32_t domid, aodev->update_json); if (rc) goto out; =20 + rc =3D libxl_devid_to_device_usbctrl(CTX, domid, usbdev->ctrl, &usbctr= l); + if (rc) goto out; + /* do actual adding usb device operation */ - rc =3D do_usbdev_add(gc, domid, usbdev, aodev->update_json); + switch (usbctrl.type) { + case LIBXL_USBCTRL_TYPE_PV: + busid =3D usbdev_busaddr_to_busid(gc, usbdev->u.hostdev.hostbus, + usbdev->u.hostdev.hostaddr); + if (!busid) { + rc =3D ERROR_FAIL; + goto out; + } + + rc =3D libxl__device_usbdev_add_xenstore(gc, domid, usbdev, + LIBXL_USBCTRL_TYPE_PV, + aodev->update_json); + if (rc) goto out; + + rc =3D usbback_dev_assign(gc, busid); + if (rc) { + libxl__device_usbdev_remove_xenstore(gc, domid, usbdev, + LIBXL_USBCTRL_TYPE_PV); + goto out; + } + break; + case LIBXL_USBCTRL_TYPE_QUSB: + rc =3D libxl__device_usbdev_add_xenstore(gc, domid, usbdev, + LIBXL_USBCTRL_TYPE_QUSB, + aodev->update_json); + if (rc) goto out; + + break; + case LIBXL_USBCTRL_TYPE_DEVICEMODEL: + rc =3D libxl__device_usbdev_add_xenstore(gc, domid, usbdev, + LIBXL_USBCTRL_TYPE_DEVICEMO= DEL, + aodev->update_json); + if (rc) goto out; + + rc =3D libxl__device_usbdev_add_hvm(gc, domid, usbdev); + if (rc) { + libxl__device_usbdev_remove_xenstore(gc, domid, usbdev, + LIBXL_USBCTRL_TYPE_DEVICEMODE= L); + goto out; + } + break; + default: + LOGD(ERROR, domid, "Unsupported usb controller type"); + rc =3D ERROR_FAIL; + goto out; + } + + rc =3D 0; =20 out: libxl_device_usbctrl_dispose(&usbctrl); aodev->rc =3D rc; aodev->callback(egc, aodev); - return; } =20 LIBXL_DEFINE_DEVICE_ADD(usbdev) --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761537; cv=none; d=zoho.com; s=zohoarc; b=knHRNyzImQKg8WZPYEt/c3kn7nDWhSu9LuJrleyA9okFXMHbPo0QYix7ov22H1lksqHkhEF7tfG5TpSRbCAmUUN6oPOgYlnOvqr9nkE0U0rU2XZYLNkGxwcDF88m8oxo0MansA6MgtECFbv5Xt5lHiWozW9LehlDwhhzORc9aWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761537; 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=BAR/tZtFqMea96lt84G+Y8mtRMjpSdSVaj1SZf3HGUY=; b=T/EiZjNtJJPWbTOViJqqGk+PeJaVh/fn9p15ejM98RiCqlGrDwQnadfZWPwDBejc9O+m5pzfzSrBIlWDAlJFkzF0GW52FNIPpSHxFxtACxOX8OkFke8FY0FXzFGsGymcKHGb54AHilNci6Oy4XgKEsOEZ3mFRBA2FmpC8LfBBqc= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761537419841.251737234037; Fri, 2 Aug 2019 08:58:57 -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 1htZwP-0005rK-Gy; Fri, 02 Aug 2019 15:58:01 +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 1htZwP-0005qv-37 for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:01 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4c0f9440-b53e-11e9-93aa-3b465ba5a6ef; Fri, 02 Aug 2019 15:57:58 +0000 (UTC) X-Inumbo-ID: 4c0f9440-b53e-11e9-93aa-3b465ba5a6ef 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: qYRdTk2KQiWh5YL8vxxW8ipoOFKvX4nFjZGSIMmptrG5pjopCSJ8uxoDPp0KMM8/TtML4bzq74 9IFvxpiOqwAHT12Sp7AQp3yJGuwzUFrfIVXJDrE6AkVpETbl+t+S3knwMDuXUHUrTgcn3IJJdF LHRllUv4kNha9iMvSc9ZAjDvWq+ieP5m/5fpwSJueJ1srVebbU5Vplm87UnNBXP7ZOgZyNLuev DPvn3ubJ/w9zBS/LI2lK27/8WHo+zMQtuxLC7enDIVQIIfBtR8eEE/qFBNRhwfu2gwyWx83Sos Jkk= X-SBRS: 2.7 X-MesageID: 3951217 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,338,1559534400"; d="scan'208";a="3951217" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:47 +0100 Message-ID: <20190802153606.32061-17-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 16/35] libxl: Inline do_usbdev_remove into libxl__device_usbdev_remove 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" Having the function do_usbdev_remove makes it harder to add asynchronous calls into it. Move its body back into libxl__device_usbdev_remove and adjust the latter as there are no reason to have a separated function. No functional changes. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_usb.c | 63 +++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c index 43c8ad3ee3..cc176f6d01 100644 --- a/tools/libxl/libxl_usb.c +++ b/tools/libxl/libxl_usb.c @@ -1655,17 +1655,38 @@ static void libxl__device_usbdev_add(libxl__egc *eg= c, uint32_t domid, LIBXL_DEFINE_DEVICE_ADD(usbdev) static LIBXL_DEFINE_DEVICES_ADD(usbdev) =20 -static int do_usbdev_remove(libxl__gc *gc, uint32_t domid, - libxl_device_usbdev *usbdev) +/* Operation to remove usb device. + * + * Generally, it does: + * 1) check if the usb device is assigned to the domain + * 2) remove the usb device from xenstore controller/port. + * 3) unbind usb device from usbback and rebind to its original driver. + * If usb device has many interfaces, do it to each interface. + */ +static int libxl__device_usbdev_remove(libxl__gc *gc, uint32_t domid, + libxl_device_usbdev *usbdev) { int rc; char *busid; libxl_device_usbctrl usbctrl; =20 + if (usbdev->ctrl < 0 || usbdev->port < 1) { + LOGD(ERROR, domid, "Invalid USB device"); + return ERROR_FAIL; + } + libxl_device_usbctrl_init(&usbctrl); rc =3D libxl_devid_to_device_usbctrl(CTX, domid, usbdev->ctrl, &usbctr= l); if (rc) goto out; =20 + if (usbctrl.backend_domid !=3D LIBXL_TOOLSTACK_DOMID) { + LOGD(ERROR, domid, + "Don't support removing USB device from non-Dom0 backend"); + rc =3D ERROR_INVAL; + goto out; + } + + /* do actual removing usb device operation */ switch (usbctrl.type) { case LIBXL_USBCTRL_TYPE_PV: busid =3D usbdev_busid_from_ctrlport(gc, domid, usbdev, usbctrl.ty= pe); @@ -1743,44 +1764,6 @@ static int do_usbdev_remove(libxl__gc *gc, uint32_t = domid, return rc; } =20 -/* Operation to remove usb device. - * - * Generally, it does: - * 1) check if the usb device is assigned to the domain - * 2) remove the usb device from xenstore controller/port. - * 3) unbind usb device from usbback and rebind to its original driver. - * If usb device has many interfaces, do it to each interface. - */ -static int libxl__device_usbdev_remove(libxl__gc *gc, uint32_t domid, - libxl_device_usbdev *usbdev) -{ - libxl_device_usbctrl usbctrl; - int rc; - - if (usbdev->ctrl < 0 || usbdev->port < 1) { - LOGD(ERROR, domid, "Invalid USB device"); - return ERROR_FAIL; - } - - libxl_device_usbctrl_init(&usbctrl); - rc =3D libxl_devid_to_device_usbctrl(CTX, domid, usbdev->ctrl, &usbctr= l); - if (rc) goto out; - - if (usbctrl.backend_domid !=3D LIBXL_TOOLSTACK_DOMID) { - LOGD(ERROR, domid, - "Don't support removing USB device from non-Dom0 backend"); - rc =3D ERROR_INVAL; - goto out; - } - - /* do actual removing usb device operation */ - rc =3D do_usbdev_remove(gc, domid, usbdev); - -out: - libxl_device_usbctrl_dispose(&usbctrl); - return rc; -} - int libxl_device_usbdev_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_usbdev *usbdev, const libxl_asyncop_how *ao_how) --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761550; cv=none; d=zoho.com; s=zohoarc; b=HZ1/rb0//+yvY54HYcYggySLPiqIPLndzWuRm7TAwinWxoT4Ek7e95rcfNwrw1TzC342irZA9C/9NkseCkNyt9Utj2ZNH2HdDKOSMWej8VgV0KoM8utQjZ3TQSLjGrWY3TnLoORzfmUE1vq9z1h+ezTXCkiNQ0Pxhgx9ATuBntI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761550; 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=K5lxNnflLRBtCR4waZEUGjXH1U1iZjEY2kixgF5LjnU=; b=aVix0dM2KWenzYny0wft10kyl7AV8V9uKfC13Jc6T+kZIooQdm+xs5Chu5c16gBB6BbyCVskRHmxMV6IjHLSWD1GjBghFdFzHiqXOrs1iM5a9Tzxa4QVsxSLunldKdANRU+Vt1sAfRo6HvAj0tNDGJSyHrRIr6eJ0vwGMtH3VpU= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761550324895.4794522288063; Fri, 2 Aug 2019 08:59:10 -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 1htZwZ-0005zp-2I; Fri, 02 Aug 2019 15:58:11 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwX-0005xR-HD for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:09 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 51e265e2-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:07 +0000 (UTC) X-Inumbo-ID: 51e265e2-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Zwo0tK+j90azTdoeZCpSfruYC0ajv+jLcIcd/1dwkrUU2YUdyF6Za4iMxcHxqkb4Arki+1N0r0 H08NZPnMGQwbeJnVa5PiZYBsyMXhlGh5csnmL4VsM6vQJeWvvXO4ner4fIDDgqvA7yxWY3CBLA mf5Za5vn1MF1SXc+BdO8OJ+RbXf57qRxeqp7rYUN5Qyem1DSN1NH1KK2juDL9y4dGfKmsq6jSK GD7r9DDHKrG/BzhZypEMJolTe7+nlSDKWjjg0F24VGOF+bo4Jl/8nKmFml90h2zP1Wfbj0jUim g9g= X-SBRS: 2.7 X-MesageID: 3911349 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3911349" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:48 +0100 Message-ID: <20190802153606.32061-18-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 17/35] libxl: Add libxl__ev_qmp to libxl__ao_device 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" `aodev->qmp' is initialised in libxl__prepare_ao_device(), but since there isn't a single exit path for a `libxl__ao_device', users of this new `qmp' field will have to disposed of it. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_device.c | 2 ++ tools/libxl/libxl_internal.h | 1 + 2 files changed, 3 insertions(+) diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 1941fe780a..1402b61a81 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -644,6 +644,8 @@ void libxl__prepare_ao_device(libxl__ao *ao, libxl__ao_= device *aodev) * without actually calling any hotplug script */ libxl__async_exec_init(&aodev->aes); libxl__ev_child_init(&aodev->child); + + libxl__ev_qmp_init(&aodev->qmp); } =20 /* multidev */ diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 7cabfd61b7..cc9318f33a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2622,6 +2622,7 @@ struct libxl__ao_device { bool update_json; /* for asynchronous execution of synchronous-only syscalls etc. */ libxl__ev_child child; + libxl__ev_qmp qmp; }; =20 /* --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761557; cv=none; d=zoho.com; s=zohoarc; b=FBlsqGeNI+Mu+btGe/nFKMFnR14kXIpucZ5OQuvMnHXg5EW5h9Jq7UjoCNsMeoeTJwlXct9O5GABvacDop+jyM0xVuOkWk1LJkrV+2ybeo9BvSbaiOrJ7gk7YBE5Ne4xXJqj32vJU0RfRkv2TKi+UqZOU29tpeyEWuxq4H6J2Ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761557; 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=Cb2BpOEVAbJU5esuYLUMnbRm6RVFCqU6FKo4VIfRNKg=; b=e3hMpZnh0jJO4HzJyHhvrUqnLSZ9rSlAUUJU1L+42v8hp99VnsNtUyuaKE9K/0Jq3PJdcvT2q32l7Vm4nWhcGzbSMX+TBKx5270XyDIkb3y4jymiLLT/SUzufYXBmYOfgnhFn5fas6pqW/VY+q6mQhvJy+WYV8H9yG0a6z6XR7E= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761557010905.7442191185847; Fri, 2 Aug 2019 08:59:17 -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 1htZwj-0006CJ-0M; Fri, 02 Aug 2019 15:58:21 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwg-000681-NY for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:18 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 577fb2b2-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:17 +0000 (UTC) X-Inumbo-ID: 577fb2b2-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: /dKiIlC9o2Aom6t1j2477ZEZxP3y3UnU3ECXNVXeJ5wvCPxGdntEA7G814F4ozESYvZZRBhs3e ZvTQeM/nZjdhpiULCcoXky/UA8xfEQ5XGnCgV3w9VtmLFSqDAPLRrT7OdYgBeJ1dxaeeFeo4uq Sxfcaod4zcA/n79Y0p7a4oIwQTwGb4shv4Ui+Z684DrONwyzvcVAHCF17aptghGNcn0RlbDn8N bHVLDqX6FCp3YrQw8w+KA0LeTrprQ/8Xe1LUQGOVx/Ixip5WrZztMnOJfW7hNsThUW7dIHYOLW mFU= X-SBRS: 2.7 X-MesageID: 3787839 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3787839" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:49 +0100 Message-ID: <20190802153606.32061-19-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 18/35] libxl: Add device_{config, type} to libxl__ao_device 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" These two fields help to give more information about the device been hotplug/hotunplug to callbacks. There is already `dev' of type `libxl__device', but it is mostly useful when the backend/frontend is xenstore. Some device (like `usbdev') don't have devid, so `dev' can't be used. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_internal.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index cc9318f33a..8dea44b221 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2623,6 +2623,12 @@ struct libxl__ao_device { /* for asynchronous execution of synchronous-only syscalls etc. */ libxl__ev_child child; libxl__ev_qmp qmp; + /* 'device_config' can be used to to pass to callbacks a pointer of one + * of the type 'libxl_device_$type' corresponding to the device been + * hotplug. 'device_type' should have the corresponding + * 'libxl__$type_devtype'. */ + void *device_config; + const libxl__device_type *device_type; }; =20 /* --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761549; cv=none; d=zoho.com; s=zohoarc; b=UnqtRgmq3kS+mIM1sCqVqH6XrCkdvaXYAw5uBPC7K3zrXxXnJlAGrlC3frUmrkRzxTMF+Ow1il33lJ65QQHmKIbHqZD06IZjQIBNyWKHgPcVTcNO2KGa/JP8W4n0S00KaYUo9aqzFmLwMnMhuAEfOML1DQmX+AG6U9ZXB5aEvPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761549; 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=IbTGem+5RLZ7jyshJ47eY2sQck9UXQwjx9mu22VOIl0=; b=l98/bLM4s0HLAHlHxLpO1dXNiXiW1fpTMR9ZJq3mJfTvKiUhk57yHcqN3YwnRx/E0WkxYELnr0ZD6x9DJr42E4DMqnCy0z3F65uhnkiJio1PtwBlI6LSOzwdSd19lOmCQ9C+tS+bnAbZzRjZPH7vakQEq/fFNrGyD599Q9LdC4g= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761549754594.9196939143385; Fri, 2 Aug 2019 08:59:09 -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 1htZwY-0005yY-BZ; Fri, 02 Aug 2019 15:58:10 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwW-0005wK-3w for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:08 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 510c3c92-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:06 +0000 (UTC) X-Inumbo-ID: 510c3c92-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: KfWsUDIWZ5u0EbKTxoGQ5k0+U5xFavKOzJHqnjLVSITuUIafDRNOOyNLEdPCfWp8R9wseRlRe6 1gg+baddVCwBQMebyPIDFahy/GXTEv3+kC0pLo1zwskxDlhkiNOjVaT6K5cdRhpzDRZIqqz3qz kvh6d7LNEOYlgmYNDSgH5GQzJBucygHXtU05G0KRGxpZrbfLW0gMBsFhAVqJlYRcfhAR1YEA+I XhEQGzqrYysgspnJGwmhlH/4c6DvmSE/kX1r11pG0j6fIckLLGDIAP4/A7WvIFcfihceP1VSsa Z3s= X-SBRS: 2.7 X-MesageID: 3911363 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3911363" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:50 +0100 Message-ID: <20190802153606.32061-20-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 19/35] libxl_usb: Make libxl__device_usbctrl_add uses ev_qmp 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" Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_usb.c | 93 ++++++++++++++++++++++++++++++++++------- 1 file changed, 77 insertions(+), 16 deletions(-) diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c index cc176f6d01..5975c1d192 100644 --- a/tools/libxl/libxl_usb.c +++ b/tools/libxl/libxl_usb.c @@ -350,34 +350,37 @@ static char *pvusb_get_device_type(libxl_usbctrl_type= type) * - usb-ehci (version=3D2), always 6 ports * - nec-usb-xhci (version=3D3), up to 15 ports */ -static int libxl__device_usbctrl_add_hvm(libxl__gc *gc, uint32_t domid, +static int libxl__device_usbctrl_add_hvm(libxl__gc *gc, libxl__ev_qmp *qmp, libxl_device_usbctrl *usbctrl) { - flexarray_t *qmp_args; - - qmp_args =3D flexarray_make(gc, 8, 1); + libxl__json_object *qmp_args =3D NULL; =20 switch (usbctrl->version) { case 1: - flexarray_append_pair(qmp_args, "driver", "piix3-usb-uhci"); + libxl__qmp_param_add_string(gc, &qmp_args, + "driver", "piix3-usb-uhci"); break; case 2: - flexarray_append_pair(qmp_args, "driver", "usb-ehci"); + libxl__qmp_param_add_string(gc, &qmp_args, + "driver", "usb-ehci"); break; case 3: - flexarray_append_pair(qmp_args, "driver", "nec-usb-xhci"); - flexarray_append_pair(qmp_args, "p2", GCSPRINTF("%d", usbctrl->por= ts)); - flexarray_append_pair(qmp_args, "p3", GCSPRINTF("%d", usbctrl->por= ts)); + libxl__qmp_param_add_string(gc, &qmp_args, + "driver", "nec-usb-xhci"); + libxl__qmp_param_add_string(gc, &qmp_args, "p2", + GCSPRINTF("%d", usbctrl->ports)); + libxl__qmp_param_add_string(gc, &qmp_args, "p3", + GCSPRINTF("%d", usbctrl->ports)); break; default: assert(0); /* Should not be possible. */ return ERROR_INVAL; } =20 - flexarray_append_pair(qmp_args, "id", - GCSPRINTF("xenusb-%d", usbctrl->devid)); + libxl__qmp_param_add_string(gc, &qmp_args, "id", + GCSPRINTF("xenusb-%d", usbctrl->devid)); =20 - return libxl__qmp_run_command_flexarray(gc, domid, "device_add", qmp_a= rgs); + return libxl__ev_qmp_send(gc, qmp, "device_add", qmp_args); } =20 /* Send qmp commands to delete a usb controller in qemu. */ @@ -432,6 +435,13 @@ static int libxl__device_usbdev_del_hvm(libxl__gc *gc,= uint32_t domid, =20 static LIBXL_DEFINE_UPDATE_DEVID(usbctrl) =20 +static void device_usbctrl_add_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc); +static void device_usbctrl_add_qmp_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *r, int rc); +static void device_usbctrl_add_done(libxl__egc *egc, + libxl__ao_device *aodev, int rc); + /* AO operation to add a usb controller. * * Generally, it does: @@ -452,6 +462,10 @@ static void libxl__device_usbctrl_add(libxl__egc *egc,= uint32_t domid, libxl__device *device; int rc; =20 + /* Store *usbctrl to be used by callbacks */ + aodev->device_config =3D usbctrl; + aodev->device_type =3D &libxl__usbctrl_devtype; + rc =3D libxl__device_usbctrl_setdefault(gc, domid, usbctrl, aodev->update_json); if (rc < 0) goto out; @@ -466,14 +480,25 @@ static void libxl__device_usbctrl_add(libxl__egc *egc= , uint32_t domid, GCNEW(device); rc =3D libxl__device_from_usbctrl(gc, domid, usbctrl, device); if (rc) goto outrm; + aodev->dev =3D device; =20 if (device->backend_kind =3D=3D LIBXL__DEVICE_KIND_NONE) { - rc =3D libxl__device_usbctrl_add_hvm(gc, domid, usbctrl); + libxl__ev_qmp *const qmp =3D &aodev->qmp; + + rc =3D libxl__ev_time_register_rel(ao, &aodev->timeout, + device_usbctrl_add_timeout, + LIBXL_QMP_CMD_TIMEOUT * 1000); if (rc) goto outrm; - goto out; + + qmp->ao =3D ao; + qmp->domid =3D domid; + qmp->payload_fd =3D -1; + qmp->callback =3D device_usbctrl_add_qmp_cb; + rc =3D libxl__device_usbctrl_add_hvm(gc, qmp, usbctrl); + if (rc) goto outrm; + return; } =20 - aodev->dev =3D device; aodev->action =3D LIBXL__DEVICE_ACTION_ADD; libxl__wait_device_connection(egc, aodev); return; @@ -481,9 +506,45 @@ static void libxl__device_usbctrl_add(libxl__egc *egc,= uint32_t domid, outrm: libxl__device_usbctrl_del_xenstore(gc, domid, usbctrl); out: + device_usbctrl_add_done(egc, aodev, rc); +} + +static void device_usbctrl_add_timeout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc) +{ + EGC_GC; + libxl__ao_device *aodev =3D CONTAINER_OF(ev, *aodev, timeout); + + if (rc =3D=3D ERROR_TIMEDOUT) + LOGD(ERROR, aodev->dev->domid, "Adding usbctrl to QEMU timed out"); + device_usbctrl_add_qmp_cb(egc, &aodev->qmp, NULL, rc); +} + +static void device_usbctrl_add_qmp_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *r, + int rc) +{ + EGC_GC; + libxl__ao_device *aodev =3D CONTAINER_OF(qmp, *aodev, qmp); + libxl_device_usbctrl *const usbctrl =3D aodev->device_config; + + if (rc) + libxl__device_usbctrl_del_xenstore(gc, aodev->dev->domid, usbctrl); + + device_usbctrl_add_done(egc, aodev, rc); +} + +static void device_usbctrl_add_done(libxl__egc *egc, + libxl__ao_device *aodev, + int rc) +{ + EGC_GC; + libxl__ev_qmp_dispose(gc, &aodev->qmp); + libxl__ev_time_deregister(gc, &aodev->timeout); aodev->rc =3D rc; aodev->callback(egc, aodev); - return; } =20 LIBXL_DEFINE_DEVICE_ADD(usbctrl) --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761530; cv=none; d=zoho.com; s=zohoarc; b=oNJybKmOgEBvqzMKR3NbDwX5SNWRCS8xsyJhOHyf1oC4JEfMcCs3Wt9hZIUSPeapNlACAmNve7Wwy2KX/ehaKA/sH0LjD9KVTCiW7aNcp8kLPwb8a6J/An1dQwW3Xwx575QfUAh7f2FTgSKVgL8f0VuPGogtPkQlOa+7VFpFJ1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761530; 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=3jmNiQEt1slMzmeb1+7UZUBKfvAHbp8/DbX0mwCVp20=; b=Bovf7QcXR8DBp2SCv20X5fztSEijZuajVTecn5dn/++cSyVZsCoaABFdGFVcPkBOEl/si1JHwCjkwDa4qQG68jvX+aR/8L53Xs0Rt9O+0leLlLxU9iwNWuqjVl7K5wGI2NQ+GpJLAYgu+yi5n2VWtKp3iIizn6VYxKpTozqc3V0= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761530933359.8121141519258; Fri, 2 Aug 2019 08:58:50 -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 1htZwH-0005mq-4A; Fri, 02 Aug 2019 15:57:53 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwF-0005ma-Nj for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:57:51 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 46febe8e-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:57:49 +0000 (UTC) X-Inumbo-ID: 46febe8e-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: VXq2FcEM5kKhzfKqIX5nsX4YRQ0PoIsi4lEbUMFPwjRCxdIwJek4Eeodp6uJKChEZqanWybtRG SAZknu9r6Ue4o+D3NGWTG8Oca78PaYfrhM807ByuIJuk1KOODVZKtMAEhS9CYjQ0ggWF+b+VFD GxcYDTuQlcKvb33dmxtWBPYpmvCSIkO2pKRS+y7BQ2zYXgei8yRvXzt3Vo8yLOaTkVkzfOwDyg dBAkC/Ne/pCkMaMU1qpkTaZ4NmIxe0Iu1sPrC/NmbWz3hdOxcrjWQTzPp2aWqYRSwQyFkwPGSF tvo= X-SBRS: 2.7 X-MesageID: 3931648 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3931648" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:51 +0100 Message-ID: <20190802153606.32061-21-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 20/35] libxl_usb: Make libxl__initiate_device_usbctrl_remove uses ev_qmp 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" Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_usb.c | 97 +++++++++++++++++++++++++++++++++-------- 1 file changed, 79 insertions(+), 18 deletions(-) diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c index 5975c1d192..92eeeb27f0 100644 --- a/tools/libxl/libxl_usb.c +++ b/tools/libxl/libxl_usb.c @@ -384,15 +384,16 @@ static int libxl__device_usbctrl_add_hvm(libxl__gc *g= c, libxl__ev_qmp *qmp, } =20 /* Send qmp commands to delete a usb controller in qemu. */ -static int libxl__device_usbctrl_del_hvm(libxl__gc *gc, uint32_t domid, +static int libxl__device_usbctrl_del_hvm(libxl__gc *gc, + libxl__ev_qmp *qmp, int devid) { - flexarray_t *qmp_args; + libxl__json_object *qmp_args =3D NULL; =20 - qmp_args =3D flexarray_make(gc, 2, 1); - flexarray_append_pair(qmp_args, "id", GCSPRINTF("xenusb-%d", devid)); + libxl__qmp_param_add_string(gc, &qmp_args, + "id", GCSPRINTF("xenusb-%d", devid)); =20 - return libxl__qmp_run_command_flexarray(gc, domid, "device_del", qmp_a= rgs); + return libxl__ev_qmp_send(gc, qmp, "device_del", qmp_args); } =20 /* Send qmp commands to create a usb device in qemu. */ @@ -559,6 +560,13 @@ static int libxl__device_usbdev_list_for_usbctrl(libxl= __gc *gc, uint32_t domid, static int libxl__device_usbdev_remove(libxl__gc *gc, uint32_t domid, libxl_device_usbdev *usbdev); =20 +static void device_usbctrl_remove_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc); +static void device_usbctrl_remove_qmp_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *resp, int rc); +static void device_usbctrl_remove_done(libxl__egc *egc, + libxl__ao_device *, int rc); + /* AO function to remove a usb controller. * * Generally, it does: @@ -578,13 +586,18 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc= *egc, int i, rc; uint32_t domid =3D aodev->dev->domid; int usbctrl_devid =3D aodev->dev->devid; - libxl_device_usbctrl usbctrl; + libxl_device_usbctrl *usbctrl; =20 - libxl_device_usbctrl_init(&usbctrl); + GCNEW(usbctrl); + libxl_device_usbctrl_init(usbctrl); rc =3D libxl_devid_to_device_usbctrl(CTX, domid, usbctrl_devid, - &usbctrl); + usbctrl); if (rc) goto out; =20 + /* Store *usbctrl to be used by callbacks */ + aodev->device_config =3D usbctrl; + aodev->device_type =3D &libxl__usbctrl_devtype; + /* Remove usb devices first */ rc =3D libxl__device_usbdev_list_for_usbctrl(gc, domid, usbctrl_devid, &usbdevs, &num_usbdev); @@ -599,24 +612,72 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc= *egc, } } =20 - if (usbctrl.type =3D=3D LIBXL_USBCTRL_TYPE_DEVICEMODEL) { - rc =3D libxl__device_usbctrl_del_hvm(gc, domid, usbctrl_devid); - if (!rc) - libxl__device_usbctrl_del_xenstore(gc, domid, &usbctrl); - goto out; + if (usbctrl->type =3D=3D LIBXL_USBCTRL_TYPE_DEVICEMODEL) { + libxl__ev_qmp *const qmp =3D &aodev->qmp; + + rc =3D libxl__ev_time_register_rel(ao, &aodev->timeout, + device_usbctrl_remove_timeout, + LIBXL_QMP_CMD_TIMEOUT * 1000); + if (rc) goto out; + + qmp->ao =3D ao; + qmp->domid =3D domid; + qmp->callback =3D device_usbctrl_remove_qmp_cb; + qmp->payload_fd =3D -1; + rc =3D libxl__device_usbctrl_del_hvm(gc, qmp, usbctrl_devid); + if (rc) goto out; + return; } =20 - libxl_device_usbctrl_dispose(&usbctrl); + libxl_device_usbctrl_dispose(usbctrl); =20 /* Remove usbctrl */ - libxl__initiate_device_generic_remove(egc, aodev); + libxl__initiate_device_generic_remove(egc, aodev); /* must be last */ return; - out: - libxl_device_usbctrl_dispose(&usbctrl); + device_usbctrl_remove_done(egc, aodev, rc); /* must be last */ +} + +static void device_usbctrl_remove_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc) +{ + EGC_GC; + libxl__ao_device *aodev =3D CONTAINER_OF(ev, *aodev, timeout); + + if (rc =3D=3D ERROR_TIMEDOUT) + LOGD(ERROR, aodev->dev->domid, + "Removing usbctrl from QEMU timed out"); + device_usbctrl_remove_qmp_cb(egc, &aodev->qmp, NULL, rc); +} + +static void device_usbctrl_remove_qmp_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *resp, + int rc) +{ + EGC_GC; + libxl__ao_device *aodev =3D CONTAINER_OF(qmp, *aodev, qmp); + libxl_device_usbctrl *const usbctrl =3D aodev->device_config; + + if (!rc) + libxl__device_usbctrl_del_xenstore(gc, aodev->dev->domid, usbctrl); + + device_usbctrl_remove_done(egc, aodev, rc); +} + +static void device_usbctrl_remove_done(libxl__egc *egc, + libxl__ao_device *aodev, + int rc) +{ + EGC_GC; + libxl_device_usbctrl *const usbctrl =3D aodev->device_config; + + libxl_device_usbctrl_dispose(usbctrl); + libxl__ev_qmp_dispose(gc, &aodev->qmp); + libxl__ev_time_deregister(gc, &aodev->timeout); + aodev->rc =3D rc; aodev->callback(egc, aodev); - return; } =20 static int libxl__usbctrl_from_xenstore(libxl__gc *gc, --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761540; cv=none; d=zoho.com; s=zohoarc; b=LqlyDOTXUx3Xy1NY6wl/xjqmOkvNNzfrgASXNt8NA8H1WTopn91k+SSvyb9/2aySVbSyzALff+/8fONSzlJbMnc7730WxzzGgtAlGkLWE70XK0jWkDiNEQDBqcLi7BGzdPMcjfkeztiaIUfdmlsbpVv4faSIvdbhyEn0JRNRxXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761540; 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=1oYH51GV18eTDh9KDG22pdjeoYGaaW/ZPEbaclHyuYE=; b=GhIlaZBPHyIt0L0zi3nnAkD41nZzNlEhBe0ASGSbrU9J4lt9lWYiLqzR2OfhJooDvhPMuIvrKTlCp0v3ntQhnUJMFgYd7S8991HSKzuq5QinkW6cDkQmV8eGHXVaBRJoMmmw892waW4Mt2gl2hEVxly8aYfmQZarwaP+hJ5+O3A= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761540857168.46586178301345; Fri, 2 Aug 2019 08:59:00 -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 1htZws-0006Tn-Ie; Fri, 02 Aug 2019 15:58:30 +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 1htZwr-0006S5-Mi for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:29 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5d25b412-b53e-11e9-bdca-4ff00e5ac374; Fri, 02 Aug 2019 15:58:27 +0000 (UTC) X-Inumbo-ID: 5d25b412-b53e-11e9-bdca-4ff00e5ac374 Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: VVqjn1/GqfDHhGXCJvgjdlpbVgqYW7vaIxLCSgbJmDyxN1B68mDb3XMrtVj+nCAbUP8sllDudj ChG6t8cucofw6cYS44eMesIee4scPq5VLZYxLMlIHqhzV75wg8SjzkjaeZER6RUKrdmz62YWg2 TGmcI1Rqz7yWIXUSVuVvz0xKudpfBpyCMDK7DDwrceRQZAdrrxoqFVYrNnASq4xL6s8WA9eHL3 4SwBKqszA1EXXMZkR59hVi4Rt99sz+OIaUt7qEYAdY/alXx8u8puC1O1E3Navs3C6c5HqrFLaq NIw= X-SBRS: 2.7 X-MesageID: 3787851 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3787851" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:52 +0100 Message-ID: <20190802153606.32061-22-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 21/35] libxl_usb: Make libxl__device_usbdev_add uses ev_qmp 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" Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_usb.c | 99 +++++++++++++++++++++++++++++++++-------- 1 file changed, 81 insertions(+), 18 deletions(-) diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c index 92eeeb27f0..6b3e388a18 100644 --- a/tools/libxl/libxl_usb.c +++ b/tools/libxl/libxl_usb.c @@ -397,26 +397,25 @@ static int libxl__device_usbctrl_del_hvm(libxl__gc *g= c, } =20 /* Send qmp commands to create a usb device in qemu. */ -static int libxl__device_usbdev_add_hvm(libxl__gc *gc, uint32_t domid, +static int libxl__device_usbdev_add_hvm(libxl__gc *gc, libxl__ev_qmp *qmp, libxl_device_usbdev *usbdev) { - flexarray_t *qmp_args; + libxl__json_object *qmp_args =3D NULL; =20 - qmp_args =3D flexarray_make(gc, 12, 1); - flexarray_append_pair(qmp_args, "id", - GCSPRINTF("xenusb-%d-%d", - usbdev->u.hostdev.hostbus, - usbdev->u.hostdev.hostaddr)); - flexarray_append_pair(qmp_args, "driver", "usb-host"); - flexarray_append_pair(qmp_args, "bus", - GCSPRINTF("xenusb-%d.0", usbdev->ctrl)); - flexarray_append_pair(qmp_args, "port", GCSPRINTF("%d", usbdev->port)); - flexarray_append_pair(qmp_args, "hostbus", - GCSPRINTF("%d", usbdev->u.hostdev.hostbus)); - flexarray_append_pair(qmp_args, "hostaddr", - GCSPRINTF("%d", usbdev->u.hostdev.hostaddr)); - - return libxl__qmp_run_command_flexarray(gc, domid, "device_add", qmp_a= rgs); + libxl__qmp_param_add_string(gc, &qmp_args, "id", + GCSPRINTF("xenusb-%d-%d", usbdev->u.hostdev.hostbus, + usbdev->u.hostdev.hostaddr)); + libxl__qmp_param_add_string(gc, &qmp_args, "driver", "usb-host"); + libxl__qmp_param_add_string(gc, &qmp_args, "bus", + GCSPRINTF("xenusb-%d.0", usbdev->ctrl)); + libxl__qmp_param_add_string(gc, &qmp_args, "port", + GCSPRINTF("%d", usbdev->port)); + libxl__qmp_param_add_string(gc, &qmp_args, "hostbus", + GCSPRINTF("%d", usbdev->u.hostdev.hostbus)); + libxl__qmp_param_add_string(gc, &qmp_args, "hostaddr", + GCSPRINTF("%d", usbdev->u.hostdev.hostaddr)); + + return libxl__ev_qmp_send(gc, qmp, "device_add", qmp_args); } =20 /* Send qmp commands to delete a usb device in qemu. */ @@ -1641,6 +1640,13 @@ static int usbback_dev_assign(libxl__gc *gc, const c= har *busid) return rc; } =20 +static void device_usbdev_add_qmp_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *r, int rc); +static void device_usbdev_add_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc); +static void device_usbdev_add_done(libxl__egc *egc, + libxl__ao_device *aodev, int rc); + /* AO operation to add a usb device. * * Generally, it does: @@ -1667,9 +1673,14 @@ static void libxl__device_usbdev_add(libxl__egc *egc= , uint32_t domid, int num_assigned; libxl_device_usbctrl usbctrl; char *busid; + bool has_callback =3D false; =20 libxl_device_usbctrl_init(&usbctrl); =20 + /* Store *usbdev to be used by callbacks */ + aodev->device_config =3D usbdev; + aodev->device_type =3D &libxl__usbdev_devtype; + /* Currently only support adding USB device from Dom0 backend. * So, if USB controller is specified, check its backend domain, * if it's not Dom0, report error. @@ -1753,12 +1764,22 @@ static void libxl__device_usbdev_add(libxl__egc *eg= c, uint32_t domid, aodev->update_json); if (rc) goto out; =20 - rc =3D libxl__device_usbdev_add_hvm(gc, domid, usbdev); + rc =3D libxl__ev_time_register_rel(ao, &aodev->timeout, + device_usbdev_add_timeout, + LIBXL_QMP_CMD_TIMEOUT * 1000); + if (rc) goto out; + + aodev->qmp.ao =3D ao; + aodev->qmp.domid =3D domid; + aodev->qmp.callback =3D device_usbdev_add_qmp_cb; + aodev->qmp.payload_fd =3D -1; + rc =3D libxl__device_usbdev_add_hvm(gc, &aodev->qmp, usbdev); if (rc) { libxl__device_usbdev_remove_xenstore(gc, domid, usbdev, LIBXL_USBCTRL_TYPE_DEVICEMODE= L); goto out; } + has_callback =3D true; break; default: LOGD(ERROR, domid, "Unsupported usb controller type"); @@ -1770,6 +1791,48 @@ static void libxl__device_usbdev_add(libxl__egc *egc= , uint32_t domid, =20 out: libxl_device_usbctrl_dispose(&usbctrl); + /* Only call _done if no callback have been setup */ + if (!has_callback) + device_usbdev_add_done(egc, aodev, rc); /* must be last */ +} + +static void device_usbdev_add_timeout(libxl__egc *egc, + libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc) +{ + EGC_GC; + libxl__ao_device *aodev =3D CONTAINER_OF(ev, *aodev, timeout); + + if (rc =3D=3D ERROR_TIMEDOUT) + LOGD(ERROR, aodev->qmp.domid, + "Adding usbdev to QEMU timed out"); + device_usbdev_add_qmp_cb(egc, &aodev->qmp, NULL, rc); +} + +static void device_usbdev_add_qmp_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *r, + int rc) +{ + EGC_GC; + libxl__ao_device *aodev =3D CONTAINER_OF(qmp, *aodev, qmp); + libxl_device_usbdev *const usbdev =3D aodev->device_config; + + if (rc) + libxl__device_usbdev_remove_xenstore(gc, qmp->domid, + usbdev, LIBXL_USBCTRL_TYPE_DEVICEMODEL); + device_usbdev_add_done(egc, aodev, rc); /* must be last */ +} + +static void device_usbdev_add_done(libxl__egc *egc, + libxl__ao_device *aodev, + int rc) +{ + EGC_GC; + + libxl__ev_time_deregister(gc, &aodev->timeout); + libxl__ev_qmp_dispose(gc, &aodev->qmp); aodev->rc =3D rc; aodev->callback(egc, aodev); } --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761551; cv=none; d=zoho.com; s=zohoarc; b=oj/uEetf/uVsfx/8Pq7ejquSyvFTIQ6IqiiqB9tg1n5Ey0pY+SgPoOHQoLDYZ9oanA6dmba8wMiAbwSr/q+EI4eCk5p//gBS+zfYjAvpZY2KzLCsYlXlIztTPORlk5O+d9bDcoJnmm1VWip8sLJ+qCul7PUxwKrFDvsrBKzeqIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761551; 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=OY8+SVYNsNlZ9MmSzhdc4gcPDdOM6rSGTMfu7hDS47Q=; b=SWleUnrhH9+wcxI9ySvXIfLeMZF9dfTm0dV8wfV9ArL3S8CWhjq0hfYT1u/F1Gpa9vpaDhmWgdEKwTiMb5UDaRaROccjWQ0w7y02V0ZB2Gr/+Zok8/RVkHKqpFPtRgpV1JTc9+EItafSZvJ8FuoWpjGexCatxN7G498xpc6T9xk= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761551737468.59154430003446; Fri, 2 Aug 2019 08:59:11 -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 1htZx0-0006hk-4M; Fri, 02 Aug 2019 15:58:38 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwy-0006es-MJ for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:36 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 62692693-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:35 +0000 (UTC) X-Inumbo-ID: 62692693-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 34CbmWvo6apQGjTt0e89UZHXb4fHJDmovNUWyVIpigV+s4NAf7W1cx50ftz35zft4yIGgH7t+f OEzVbP5DiQ6zsf7gD3exgARxluxb9Jsk8L2CGbRcJODqeKnW3mxWm7SshdDDfrDMCxLlerVxkp OhQqb2QtpcfrgHTU04gDskmkw8NCCsqQHypDOGhfMPSIqiUmnRd+I8o9FEsMp64OroHk/+FbCk v5AU7U1MrqcUFKqFHkDiTa0eBcpvGjKMUPHO20C0VC3YnTeTmpkuwG9nJ9YzPCvZLc9O/052q2 AS4= X-SBRS: 2.7 X-MesageID: 3826803 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3826803" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:53 +0100 Message-ID: <20190802153606.32061-23-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 22/35] libxl: Use aodev for libxl__device_usbdev_remove 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" This also mean libxl__initiate_device_usbctrl_remove, which uses libxl__device_usbdev_remove synchronously, needs to be updated to use it with multidev. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_usb.c | 79 +++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 18 deletions(-) diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c index 6b3e388a18..8e3a419805 100644 --- a/tools/libxl/libxl_usb.c +++ b/tools/libxl/libxl_usb.c @@ -556,9 +556,11 @@ static int libxl__device_usbdev_list_for_usbctrl(libxl= __gc *gc, uint32_t domid, libxl_device_usbdev **usb= devs, int *num); =20 -static int libxl__device_usbdev_remove(libxl__gc *gc, uint32_t domid, - libxl_device_usbdev *usbdev); +static void libxl__device_usbdev_remove(libxl__egc *egc, + uint32_t domid, libxl_device_usbdev *usbdev, libxl__ao_device *aodev); =20 +static void device_usbctrl_usbdevs_removed(libxl__egc *, + libxl__multidev *, int rc); static void device_usbctrl_remove_timeout(libxl__egc *egc, libxl__ev_time *ev, const struct timeval *requested_abs, int rc); static void device_usbctrl_remove_qmp_cb(libxl__egc *egc, @@ -566,6 +568,11 @@ static void device_usbctrl_remove_qmp_cb(libxl__egc *e= gc, static void device_usbctrl_remove_done(libxl__egc *egc, libxl__ao_device *, int rc); =20 +typedef struct { + libxl__multidev multidev; + libxl__ao_device *aodev; +} usbctrl_remove_state; + /* AO function to remove a usb controller. * * Generally, it does: @@ -586,6 +593,12 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc = *egc, uint32_t domid =3D aodev->dev->domid; int usbctrl_devid =3D aodev->dev->devid; libxl_device_usbctrl *usbctrl; + usbctrl_remove_state *ucrs; + + GCNEW(ucrs); + ucrs->aodev =3D aodev; + ucrs->multidev.callback =3D device_usbctrl_usbdevs_removed; + libxl__multidev_begin(ao, &ucrs->multidev); =20 GCNEW(usbctrl); libxl_device_usbctrl_init(usbctrl); @@ -603,14 +616,29 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc= *egc, if (rc) goto out; =20 for (i =3D 0; i < num_usbdev; i++) { - rc =3D libxl__device_usbdev_remove(gc, domid, &usbdevs[i]); - if (rc) { - LOGD(ERROR, domid, "libxl__device_usbdev_remove failed: contro= ller %d, " - "port %d", usbdevs[i].ctrl, usbdevs[i].port); - goto out; - } + libxl__ao_device *usbdev_aodev =3D + libxl__multidev_prepare(&ucrs->multidev); + usbdev_aodev->action =3D LIBXL__DEVICE_ACTION_REMOVE; + libxl__device_usbdev_remove(egc, domid, &usbdevs[i], usbdev_aodev); } =20 +out: + libxl__multidev_prepared(egc, &ucrs->multidev, rc); /* must be last */ +} + +static void device_usbctrl_usbdevs_removed(libxl__egc *egc, + libxl__multidev *multidev, + int rc) +{ + usbctrl_remove_state *ucrs =3D + CONTAINER_OF(multidev, *ucrs, multidev); + libxl__ao_device *aodev =3D ucrs->aodev; + STATE_AO_GC(aodev->ao); + libxl_device_usbctrl *const usbctrl =3D aodev->device_config; + + if (rc) goto out; + + /* Remove usbctrl */ if (usbctrl->type =3D=3D LIBXL_USBCTRL_TYPE_DEVICEMODEL) { libxl__ev_qmp *const qmp =3D &aodev->qmp; =20 @@ -620,10 +648,10 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc= *egc, if (rc) goto out; =20 qmp->ao =3D ao; - qmp->domid =3D domid; + qmp->domid =3D aodev->dev->domid; qmp->callback =3D device_usbctrl_remove_qmp_cb; qmp->payload_fd =3D -1; - rc =3D libxl__device_usbctrl_del_hvm(gc, qmp, usbctrl_devid); + rc =3D libxl__device_usbctrl_del_hvm(gc, qmp, aodev->dev->devid); if (rc) goto out; return; } @@ -1847,20 +1875,31 @@ static LIBXL_DEFINE_DEVICES_ADD(usbdev) * 2) remove the usb device from xenstore controller/port. * 3) unbind usb device from usbback and rebind to its original driver. * If usb device has many interfaces, do it to each interface. + * + * Before calling this function, aodev should be properly filled: + * aodev->ao, aodev->callback, ... */ -static int libxl__device_usbdev_remove(libxl__gc *gc, uint32_t domid, - libxl_device_usbdev *usbdev) +static void libxl__device_usbdev_remove(libxl__egc *egc, uint32_t domid, + libxl_device_usbdev *usbdev, + libxl__ao_device *aodev) { + STATE_AO_GC(aodev->ao); int rc; char *busid; libxl_device_usbctrl usbctrl; =20 + /* Store *usbdev to be used by callbacks */ + aodev->device_config =3D usbdev; + aodev->device_type =3D &libxl__usbdev_devtype; + + libxl_device_usbctrl_init(&usbctrl); + if (usbdev->ctrl < 0 || usbdev->port < 1) { LOGD(ERROR, domid, "Invalid USB device"); - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } =20 - libxl_device_usbctrl_init(&usbctrl); rc =3D libxl_devid_to_device_usbctrl(CTX, domid, usbdev->ctrl, &usbctr= l); if (rc) goto out; =20 @@ -1946,7 +1985,8 @@ static int libxl__device_usbdev_remove(libxl__gc *gc,= uint32_t domid, =20 out: libxl_device_usbctrl_dispose(&usbctrl); - return rc; + aodev->rc =3D rc; + aodev->callback(egc, aodev); } =20 int libxl_device_usbdev_remove(libxl_ctx *ctx, uint32_t domid, @@ -1955,11 +1995,14 @@ int libxl_device_usbdev_remove(libxl_ctx *ctx, uint= 32_t domid, =20 { AO_CREATE(ctx, domid, ao_how); - int rc; + libxl__ao_device *aodev; =20 - rc =3D libxl__device_usbdev_remove(gc, domid, usbdev); + GCNEW(aodev); + libxl__prepare_ao_device(ao, aodev); + aodev->action =3D LIBXL__DEVICE_ACTION_REMOVE; + aodev->callback =3D device_addrm_aocomplete; + libxl__device_usbdev_remove(egc, domid, usbdev, aodev); =20 - libxl__ao_complete(egc, ao, rc); return AO_INPROGRESS; } =20 --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761553; cv=none; d=zoho.com; s=zohoarc; b=gmdX//xx5GtQorwIXGmwOjZuYJaPN47AoWEudkfT9wcMAbXUzyqy2PJlZrkKIhaOuWw1YkBPWDyZ53u3HfgpXDtGdegLXtguH4X5H+OGuWQwnd7TdeGWDpCaIRJGnU1dWBmdnbJgoplkUMI2LB58oEklcnOAY9J39XT/hY9yOoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761553; 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=V/6Ix6jRutaui4NbiojVhlgCAVR0Jqq4toUGIRv3vo4=; b=KKJk210CdS0U+b4WeV4M9NQyD7oeoj70jbvgTzUNqA8hQ/iIN0muEXOpCX7yRYT5WBEc6llAK/RImGUdI3QldXxyV13yGStxV5EQVt4T1guVAmn6BAJwxzFmY9kqNaiKB6qp/SFBdkIadh2yZHiGcYVopxWP7fMUMt35EgogHnM= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761553482437.63372237835597; Fri, 2 Aug 2019 08:59:13 -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 1htZwX-0005xp-S7; Fri, 02 Aug 2019 15:58:09 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwV-0005w3-Qf for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:07 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 50e314fb-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:06 +0000 (UTC) X-Inumbo-ID: 50e314fb-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: DGYr0AE1MMMp0rbwzpi/gZwnTxXHizmvKuhoLEgFeHs0tdwWYSFdl1T0b/NqxG5XQOew/vlzO0 GdvX0qG2Lfbv1WTqn9hXmpKTLlaccwXys1NWgI3fu5Ywf3WcwfC0664JW3+ghEDUA4E2r2O5YO pKWYH3tWWse6jMz0gNmWC+QIc3qT4iwpUSbqNGS30GZz2o9AbFkQqhqYVFPVAYczFG+an5gBxL lWKPRmZAwl03sfR8CUyfIq/RRln4womBrZF2SMwjFk/ATyuqFLM3lSbEQ5Wh6UaDFE9gGpxZ1c MAg= X-SBRS: 2.7 X-MesageID: 3797638 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3797638" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:54 +0100 Message-ID: <20190802153606.32061-24-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 23/35] libxl: libxl__initiate_device_usbdev_remove now use ev_qmp 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" Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_usb.c | 78 +++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 10 deletions(-) diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c index 8e3a419805..2c11896f9e 100644 --- a/tools/libxl/libxl_usb.c +++ b/tools/libxl/libxl_usb.c @@ -419,18 +419,16 @@ static int libxl__device_usbdev_add_hvm(libxl__gc *gc= , libxl__ev_qmp *qmp, } =20 /* Send qmp commands to delete a usb device in qemu. */ -static int libxl__device_usbdev_del_hvm(libxl__gc *gc, uint32_t domid, +static int libxl__device_usbdev_del_hvm(libxl__gc *gc, libxl__ev_qmp *qmp, libxl_device_usbdev *usbdev) { - flexarray_t *qmp_args; + libxl__json_object *qmp_args =3D NULL; =20 - qmp_args =3D flexarray_make(gc, 2, 1); - flexarray_append_pair(qmp_args, "id", - GCSPRINTF("xenusb-%d-%d", - usbdev->u.hostdev.hostbus, - usbdev->u.hostdev.hostaddr)); + libxl__qmp_param_add_string(gc, &qmp_args, "id", + GCSPRINTF("xenusb-%d-%d", usbdev->u.hostdev.hostbus, + usbdev->u.hostdev.hostaddr)); =20 - return libxl__qmp_run_command_flexarray(gc, domid, "device_del", qmp_a= rgs); + return libxl__ev_qmp_send(gc, qmp, "device_del", qmp_args); } =20 static LIBXL_DEFINE_UPDATE_DEVID(usbctrl) @@ -1868,6 +1866,13 @@ static void device_usbdev_add_done(libxl__egc *egc, LIBXL_DEFINE_DEVICE_ADD(usbdev) static LIBXL_DEFINE_DEVICES_ADD(usbdev) =20 +static void device_usbdev_remove_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc); +static void device_usbdev_remove_qmp_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *r, int rc); +static void device_usbdev_remove_done(libxl__egc *egc, + libxl__ao_device *aodev, int rc); + /* Operation to remove usb device. * * Generally, it does: @@ -1887,6 +1892,7 @@ static void libxl__device_usbdev_remove(libxl__egc *e= gc, uint32_t domid, int rc; char *busid; libxl_device_usbctrl usbctrl; + bool has_callback =3D false; =20 /* Store *usbdev to be used by callbacks */ aodev->device_config =3D usbdev; @@ -1966,14 +1972,23 @@ static void libxl__device_usbdev_remove(libxl__egc = *egc, uint32_t domid, LIBXL_USBCTRL_TYPE_DEVICEMOD= EL); if (rc) goto out; =20 - rc =3D libxl__device_usbdev_del_hvm(gc, domid, usbdev); + rc =3D libxl__ev_time_register_rel(ao, &aodev->timeout, + device_usbdev_remove_timeout, + LIBXL_QMP_CMD_TIMEOUT * 1000); + if (rc) goto out; + + aodev->qmp.ao =3D ao; + aodev->qmp.domid =3D domid; + aodev->qmp.callback =3D device_usbdev_remove_qmp_cb; + aodev->qmp.payload_fd =3D -1; + rc =3D libxl__device_usbdev_del_hvm(gc, &aodev->qmp, usbdev); if (rc) { libxl__device_usbdev_add_xenstore(gc, domid, usbdev, LIBXL_USBCTRL_TYPE_DEVICEMOD= EL, false); goto out; } - + has_callback =3D true; break; default: LOGD(ERROR, domid, "Unsupported usb controller type"); @@ -1985,6 +2000,49 @@ static void libxl__device_usbdev_remove(libxl__egc *= egc, uint32_t domid, =20 out: libxl_device_usbctrl_dispose(&usbctrl); + /* Only call _done if no callback have been setup */ + if (!has_callback) + device_usbdev_remove_done(egc, aodev, rc); /* must be last */ +} + +static void device_usbdev_remove_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc) +{ + EGC_GC; + libxl__ao_device *aodev =3D CONTAINER_OF(ev, *aodev, timeout); + + if (rc =3D=3D ERROR_TIMEDOUT) + LOGD(ERROR, aodev->qmp.domid, + "Removing usbdev from QEMU timed out"); + device_usbdev_remove_qmp_cb(egc, &aodev->qmp, NULL, rc); +} + +static void device_usbdev_remove_qmp_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *r, + int rc) +{ + EGC_GC; + libxl__ao_device *aodev =3D CONTAINER_OF(qmp, *aodev, qmp); + libxl_device_usbdev *const usbdev =3D aodev->device_config; + + if (rc) { + libxl__device_usbdev_add_xenstore(gc, qmp->domid, usbdev, + LIBXL_USBCTRL_TYPE_DEVICEMODEL, + false); + } + + device_usbdev_remove_done(egc, aodev, rc); /* must be last */ +} + +static void device_usbdev_remove_done(libxl__egc *egc, + libxl__ao_device *aodev, + int rc) +{ + EGC_GC; + + libxl__ev_time_deregister(gc, &aodev->timeout); + libxl__ev_qmp_dispose(gc, &aodev->qmp); aodev->rc =3D rc; aodev->callback(egc, aodev); } --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761555; cv=none; d=zoho.com; s=zohoarc; b=NoyA/6VXgWi17R70qSRAxVfsBKAWq5yuU5k8TxrYpOs37xAW9gwu3QC/YUGjNlEeAL0V4ToRW753fZOoHPxEo6w9T6DChSPBCCF10kEr7ZPR32xnRs69XdnRpuRk3JztfmBKtviZz4pR1TQvpQRzJrOTdGEOs1K6vHoWDbX4/+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761555; 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=WPpvMI+/xsMEvmpXxqDpVlR6tWnoHHha+57q6ImmelY=; b=bA1ldclfSIKMSRuUsOhTACEVB7UW6CdoMi9gsxxp+a79x31qVY0n9k6sCRLFlWQrZv8aaNC2EuKmc7Tma0QU61wEJqiox7UyU13RJDgpZgJKhtJSJLksobtxw9wv6mBj0nJQq4rpCrkJVk0ppgU+eTHN9WXHIXgYYYQdBkoVG2c= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761555978570.0033455840448; Fri, 2 Aug 2019 08:59:15 -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 1htZwh-00069j-Ny; Fri, 02 Aug 2019 15:58:19 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwf-00066R-S7 for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:17 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 572c8184-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:16 +0000 (UTC) X-Inumbo-ID: 572c8184-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: KcSqSv4Os+NxNdOYh7DX71CxqjoRi3jm93ESonRPUeV9BX9W3zBOGDytULFHSD+LRt17dwfQST ku8IMZi8JCAWmIEzDoJuZJ/qdrZObaGQLNK/MHbHErQflcSwCHigBf5o7Ch2PdKMB9onICTaqk /82xZp2ay24N66SRYAiAkz8UltmotoBTJpXNV/ZzBRvdz8O+wgpI6hFS/TzarI0mFlb40gOElK DT+8wpzm9hxU0BvNhPlCwktio9YiRHr8VwKz46jTbJfO8riRsi3kM8511n7FYiZcnc8HqnmNPF eos= X-SBRS: 2.7 X-MesageID: 3787818 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3787818" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:55 +0100 Message-ID: <20190802153606.32061-25-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 24/35] libxl: Remove libxl__qmp_run_command_flexarray 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" There are no more users. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_internal.h | 3 --- tools/libxl/libxl_qmp.c | 16 ---------------- 2 files changed, 19 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 8dea44b221..5c15a73a08 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1979,9 +1979,6 @@ typedef struct libxl__qmp_handler libxl__qmp_handler; */ _hidden libxl__qmp_handler *libxl__qmp_initialize(libxl__gc *gc, uint32_t domid); -_hidden int libxl__qmp_run_command_flexarray(libxl__gc *gc, int domid, - const char *cmd, - flexarray_t *array); _hidden int libxl__qmp_pci_add(libxl__gc *gc, int d, libxl_device_pci *pci= dev); _hidden int libxl__qmp_pci_del(libxl__gc *gc, int domid, libxl_device_pci *pcidev); diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 0d6aedcc7d..c78ef4637d 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -833,22 +833,6 @@ static int qmp_run_command(libxl__gc *gc, int domid, return rc; } =20 -int libxl__qmp_run_command_flexarray(libxl__gc *gc, int domid, - const char *cmd, flexarray_t *array) -{ - libxl__json_object *args =3D NULL; - int i; - void *name, *value; - - for (i =3D 0; i < array->count; i +=3D 2) { - flexarray_get(array, i, &name); - flexarray_get(array, i + 1, &value); - libxl__qmp_param_add_string(gc, &args, (char *)name, (char *)value= ); - } - - return qmp_run_command(gc, domid, cmd, args, NULL, NULL); -} - int libxl__qmp_pci_add(libxl__gc *gc, int domid, libxl_device_pci *pcidev) { libxl__qmp_handler *qmp =3D NULL; --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761545; cv=none; d=zoho.com; s=zohoarc; b=Al0I/yyst74nEhZh2H75cGFXDfzbHzoEZcqR5M1YbRkvR8P6I/fyzMXU3/+BP1KA/gHycB7f39UWHcpRMFQNpiEK8h7EywRw4vZaB0Yst62BXiitDDmaZTa5hj+9mRwjZndRpNj5OjIj43xDtaNtJ54ZfrGcbf1+xXEwVKFACjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761545; 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=m4UCe/1PV5sYr4swZPVPRrNR9csfzqP/dCqMQGkG+3Q=; b=nnXk12hmdmjuFmkvI6GKkoLqODD4P1iz7yu9vh1yrlmD6sUeqcWdv8m0+3H9jQUEtcSmyJaeMhWMytykiK+tUFCIvP5VXhDlHwsgnWUZMKDc1SHS9QbcB6n7E7ATky/9VCVJF1EMAIeK/f38sjY2U2rhCF2gSwrEMYu6hJ39gMM= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761545521839.834185804693; Fri, 2 Aug 2019 08:59:05 -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 1htZwz-0006gm-Io; Fri, 02 Aug 2019 15:58:37 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwy-0006eI-EQ for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:36 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 61a2ee97-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:34 +0000 (UTC) X-Inumbo-ID: 61a2ee97-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 7EKsGSLKpzpsq5fIgsofCkQYL5rLoB/rMSkNSELfGw1BWZhynvVBgEufhrV1t8gyxnkNGBN6iA ck5lO2JDeogn+KxVNTo9QvSr2lY2PxA78pgOBNqM5FpEpRBlQytm/Zg6DNhRw3mgmzX2Dyhr3z k3gvHkeGZLVbEvgFLG+Aj9KPIMxQRWj+2Iz9S5OMJdzpt6RrtuONmTN9RQmp7anM9tTKK2KeeH 2rms9upg10sNu4wu6HH7iXkmVW7k+u6VQhcjvgUbFsvpdyFi1cZYeF1jq+UGbkDkm8UHAtob/U 5gQ= X-SBRS: 2.7 X-MesageID: 3826801 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3826801" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:56 +0100 Message-ID: <20190802153606.32061-26-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 25/35] libxl_pci: Coding style of do_pci_add 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" do_pci_add is going to be asynchronous, so we start by having a single path out of the function. All `return`s instead set rc and goto out. While here, some use of `rc' was used to store the return value of libxc calls, change them to store into `r'. Also, add the value of `r' in the error message of those calls. There were an `out' label that was use it seems to skip setting up the IRQ, the label has been renamed to `out_no_irq'. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_pci.c | 79 ++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 4b1aed1895..b9ca69f5f0 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -995,15 +995,19 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, uint32_t flag =3D XEN_DOMCTL_DEV_RDM_RELAXED; uint32_t domainid =3D domid; bool isstubdom =3D libxl_is_stubdom(ctx, domid, &domainid); + int r; =20 - if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) - return ERROR_FAIL; + if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) { + rc =3D ERROR_FAIL; + goto out; + } =20 if (type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { hvm =3D 1; if (libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL) < 0) { - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } switch (libxl__device_model_version_running(gc, domid)) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: @@ -1013,10 +1017,10 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, rc =3D libxl__qmp_pci_add(gc, domid, pcidev); break; default: - return ERROR_INVAL; + rc =3D ERROR_INVAL; } if ( rc ) - return ERROR_FAIL; + goto out; } =20 sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource", pcidev->d= omain, @@ -1027,7 +1031,8 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, =20 if (f =3D=3D NULL) { LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path); - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } for (i =3D 0; i < PROC_PCI_NUM_RESOURCES; i++) { if (fscanf(f, "0x%llx 0x%llx 0x%llx\n", &start, &end, &flags) !=3D= 3) @@ -1035,25 +1040,25 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, size =3D end - start + 1; if (start) { if (flags & PCI_BAR_IO) { - rc =3D xc_domain_ioport_permission(ctx->xch, domid, start,= size, 1); - if (rc < 0) { + r =3D xc_domain_ioport_permission(ctx->xch, domid, start, = size, 1); + if (r < 0) { LOGED(ERROR, domainid, - "Error: xc_domain_ioport_permission error 0x%llx= /0x%llx", - start, - size); + "xc_domain_ioport_permission 0x%llx/0x%llx (erro= r %d)", + start, size, r); fclose(f); - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } } else { - rc =3D xc_domain_iomem_permission(ctx->xch, domid, start>>= XC_PAGE_SHIFT, + r =3D xc_domain_iomem_permission(ctx->xch, domid, start>>X= C_PAGE_SHIFT, (size+(XC_PAGE_SIZE-1))>>X= C_PAGE_SHIFT, 1); - if (rc < 0) { + if (r < 0) { LOGED(ERROR, domainid, - "Error: xc_domain_iomem_permission error 0x%llx/= 0x%llx", - start, - size); + "xc_domain_iomem_permission 0x%llx/0x%llx (error= %d)", + start, size, r); fclose(f); - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } } } @@ -1064,20 +1069,24 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, f =3D fopen(sysfs_path, "r"); if (f =3D=3D NULL) { LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path); - goto out; + goto out_no_irq; } if ((fscanf(f, "%u", &irq) =3D=3D 1) && irq) { - rc =3D xc_physdev_map_pirq(ctx->xch, domid, irq, &irq); - if (rc < 0) { - LOGED(ERROR, domainid, "Error: xc_physdev_map_pirq irq=3D%d", = irq); + r =3D xc_physdev_map_pirq(ctx->xch, domid, irq, &irq); + if (r < 0) { + LOGED(ERROR, domainid, "xc_physdev_map_pirq irq=3D%d (error=3D= %d)", + irq, r); fclose(f); - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } - rc =3D xc_domain_irq_permission(ctx->xch, domid, irq, 1); - if (rc < 0) { - LOGED(ERROR, domainid, "Error: xc_domain_irq_permission irq=3D= %d", irq); + r =3D xc_domain_irq_permission(ctx->xch, domid, irq, 1); + if (r < 0) { + LOGED(ERROR, domainid, + "xc_domain_irq_permission irq=3D%d (error=3D%d)", irq, r= ); fclose(f); - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } } fclose(f); @@ -1087,22 +1096,25 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/permissive", pcidev) < 0 ) { LOGD(ERROR, domainid, "Setting permissive for device"); - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } } =20 -out: +out_no_irq: if (!isstubdom) { if (pcidev->rdm_policy =3D=3D LIBXL_RDM_RESERVE_POLICY_STRICT) { flag &=3D ~XEN_DOMCTL_DEV_RDM_RELAXED; } else if (pcidev->rdm_policy !=3D LIBXL_RDM_RESERVE_POLICY_RELAXE= D) { LOGED(ERROR, domainid, "unknown rdm check flag."); - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } - rc =3D xc_assign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev)= , flag); - if (rc < 0 && (hvm || errno !=3D ENOSYS)) { + r =3D xc_assign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev),= flag); + if (r < 0 && (hvm || errno !=3D ENOSYS)) { LOGED(ERROR, domainid, "xc_assign_device failed"); - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } } =20 @@ -1110,6 +1122,7 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, rc =3D libxl__device_pci_add_xenstore(gc, domid, pcidev, starting); else rc =3D 0; +out: return rc; } =20 --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761529; cv=none; d=zoho.com; s=zohoarc; b=bbFqhuZ/1pIu6ax9sG3o9EfWKL+ci0Y6mMnM295sQUv9i7DFON4pWN/nWc5wuxQfPCKPUvnrJiZDvXsMGes03K6FmF/aZ/yX68ZyNyjj1WSajk3RluN1OdXPt9duEVrbZ+Pf2lzBEMdsSLARLofbeDekGuVHvBvK8xWDUmLVl34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761529; 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=A4KKr/OVaKeB8FfTGYZcn8hvy3ciMJbKbBmpT0x6AuI=; b=XuYPuhfl/mpw74yG32ucBlb52Td9i30KUA4/kX0RWTGUxUrgJJOr38Q4I3CAqsSkCjvpXZjCyY4W6NpkZlOnnGK2bpzdtsml+ZQ0Ax71cyz6utMTE2kylndFfZWnDTS9jwjo9eimI6rYub074w43+a/IrTP2buJYe41qMtGmRQY= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761529747899.499425168722; Fri, 2 Aug 2019 08:58:49 -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 1htZwi-0006AU-5A; Fri, 02 Aug 2019 15:58:20 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwf-00066P-QL for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:17 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 56cb0470-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:16 +0000 (UTC) X-Inumbo-ID: 56cb0470-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 8SXjRg9qcptp5ea2C5Jc+Z1rSfAeunhsiXNVuexUmMacf8PdAY4/MSnTox7vnTa/3Z4X+EiMF5 WK+LKUPIUZ06TuU9RDMMnP8TlQCJPy+p7X8BwWUgCqcXKHvLJJNGPZ7RUFyL3J24IMuFLodJ7n 5/k4VlPPfdIqfJMKaXzAiNXx/K5GG1/i1PPJWG88Q7zSXfpLfZn1Kj8dIBf1ZKI/astLOi74sh /l6xpW2AZYncIG351NIZpr8QTDtl/l5CoGzy3zheNYWxecKHhp+FCLAeCnLTcGIFXnr+Tl+87b 5BI= X-SBRS: 2.7 X-MesageID: 3787825 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3787825" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:57 +0100 Message-ID: <20190802153606.32061-27-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 26/35] libxl_pci: Only check if qemu-dm is running in qemu-trad case 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" QEMU upstream (or qemu-xen) may not have set "running" state in xenstore. "running" with QEMU doesn't mean that the binary is running, it means that the emulation have started. When adding a pci-passthrough device to QEMU, we do so via QMP, we have a direct answer to whether QEMU is running or not, no need to check ahead. Moving the check to do it only with qemu-trad makes upcoming changes simpler. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_pci.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index b9ca69f5f0..071880b855 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -1004,13 +1004,13 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, =20 if (type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { hvm =3D 1; - if (libxl__wait_for_device_model_deprecated(gc, domid, "running", - NULL, NULL, NULL) < 0) { - rc =3D ERROR_FAIL; - goto out; - } switch (libxl__device_model_version_running(gc, domid)) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: + if (libxl__wait_for_device_model_deprecated(gc, domid, + "running", NULL, NULL, NULL) < 0) { + rc =3D ERROR_FAIL; + goto out; + } rc =3D qemu_pci_add_xenstore(gc, domid, pcidev); break; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: @@ -1395,12 +1395,11 @@ static int do_pci_remove(libxl__gc *gc, uint32_t do= mid, rc =3D ERROR_FAIL; if (type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { hvm =3D 1; - if (libxl__wait_for_device_model_deprecated(gc, domid, "running", - NULL, NULL, NULL) < 0) - goto out_fail; - switch (libxl__device_model_version_running(gc, domid)) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: + if (libxl__wait_for_device_model_deprecated(gc, domid, + "running", NULL, NULL, NULL) < 0) + goto out_fail; rc =3D qemu_pci_remove_xenstore(gc, domid, pcidev, force); break; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761547; cv=none; d=zoho.com; s=zohoarc; b=OfPVQglihLv6Jxa5+hThoBmBJWBmSmjJw9JF3kg8gDd5bP6d/tLYjRqdUb70igZr6ZIz14cKYrNLeErAVAegD84P/0cqxoVsSWkaoavJVDUzW/r7wchnyRdXiRSJWXYMKjecCVHOyCHAIjgiy38XggAQUbBY0KuhJnqml+zLfis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761547; 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=tyOALpiH2ww4hGRI5Til1sNoFkppiN7iCTeYHlkyqKo=; b=Ll+UC7XJwnZ5CTRNA4bisH+2j5pKkUkkGweQmQam2SI8jw4pUzucnyCmZ9p40PErVCaPYWl5CcKvCGC1Crw2ILIOowhu6iXG20biiL25DkSoq2e0gs2CXdLRnbXbTEBiXHPrdhe01xYtIS3N+5BKyv+ppo2e0UN/9ZeTaQvxff8= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761547109823.0834945468031; Fri, 2 Aug 2019 08:59:07 -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 1htZwU-0005uc-3e; Fri, 02 Aug 2019 15:58:06 +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 1htZwS-0005tm-Bq for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:04 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4e4939a0-b53e-11e9-a1ad-ffb9cc75931d; Fri, 02 Aug 2019 15:58:01 +0000 (UTC) X-Inumbo-ID: 4e4939a0-b53e-11e9-a1ad-ffb9cc75931d 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: EZTo8lTXZmgTU+dMVYJ0BJxfwtTobgE3Ei6AvjuVQeqwtZ+w9sfzcSGDuSH3u2KdbIUDI3Frup Gac/wVGGQNFH4eqJf7lEIHW6WJva4tL/pNmBuAvDQi3vT4HeQ+gdd93eeFSQVtlT2SL0VNP9ve RMIkZcOjSxWuIAU/Vaiiq0+1MMVhiFTORYbrGNpM62r3ShF7yPOmQ0D4+wbdFuFZcc7I6JZlfp Dk3+kijOr0BfGbNpfz+T9/o9+5r30sWz4Hie6669B4rIoXo4Y2UCRO4c0XdmrsDQNMvIrS0Qly E18= X-SBRS: 2.7 X-MesageID: 3951219 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,338,1559534400"; d="scan'208";a="3951219" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:58 +0100 Message-ID: <20190802153606.32061-28-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 27/35] libxl_pci: Use libxl__ao_device with libxl__device_pci_add 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" Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_internal.h | 7 +- tools/libxl/libxl_pci.c | 170 ++++++++++++++++++++++++++++++----- 2 files changed, 150 insertions(+), 27 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 5c15a73a08..dd9934141f 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -198,6 +198,7 @@ typedef struct libxl__json_object libxl__json_object; typedef struct libxl__carefd libxl__carefd; typedef struct libxl__ev_lock libxl__ev_lock; typedef struct libxl__dm_resume_state libxl__dm_resume_state; +typedef struct libxl__ao_device libxl__ao_device; =20 typedef struct libxl__domain_create_state libxl__domain_create_state; typedef void libxl__domain_create_cb(struct libxl__egc *egc, @@ -1592,8 +1593,9 @@ _hidden int libxl__pci_topology_init(libxl__gc *gc, =20 /* from libxl_pci */ =20 -_hidden int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, - libxl_device_pci *pcidev, bool starting); +_hidden void libxl__device_pci_add(libxl__egc *egc, uint32_t domid, + libxl_device_pci *pcidev, bool starting, + libxl__ao_device *aodev); _hidden int libxl__device_pci_destroy_all(libxl__gc *gc, uint32_t domid); _hidden bool libxl__is_igd_vga_passthru(libxl__gc *gc, const libxl_domain_config *d_confi= g); @@ -2571,7 +2573,6 @@ _hidden void libxl__kill(libxl__gc *gc, pid_t pid, in= t sig, const char *what); =20 /*----- device addition/removal -----*/ =20 -typedef struct libxl__ao_device libxl__ao_device; typedef struct libxl__multidev libxl__multidev; typedef void libxl__device_callback(libxl__egc*, libxl__ao_device*); =20 diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 071880b855..503db6c260 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -983,9 +983,24 @@ static int qemu_pci_add_xenstore(libxl__gc *gc, uint32= _t domid, return rc; } =20 -static int do_pci_add(libxl__gc *gc, uint32_t domid, - libxl_device_pci *pcidev, bool starting) +typedef struct pci_add_state { + /* filled by user of do_pci_add */ + libxl__ao_device *aodev; + libxl_domid domid; + bool starting; + void (*callback)(libxl__egc *, struct pci_add_state *, int rc); + + /* private to do_pci_add */ + libxl_device_pci *pcidev; + int pci_domid; +} pci_add_state; + +static void do_pci_add(libxl__egc *egc, + libxl_domid domid, + libxl_device_pci *pcidev, + pci_add_state *pas) { + STATE_AO_GC(pas->aodev->ao); libxl_ctx *ctx =3D libxl__gc_owner(gc); libxl_domain_type type =3D libxl__domain_type(gc, domid); char *sysfs_path; @@ -997,6 +1012,13 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, bool isstubdom =3D libxl_is_stubdom(ctx, domid, &domainid); int r; =20 + /* Convenience aliases */ + bool starting =3D pas->starting; + + /* init pci_add_state */ + pas->pcidev =3D pcidev; + pas->pci_domid =3D domid; + if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) { rc =3D ERROR_FAIL; goto out; @@ -1123,7 +1145,7 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, else rc =3D 0; out: - return rc; + pas->callback(egc, pas, rc); } =20 static int libxl__device_pci_reset(libxl__gc *gc, unsigned int domain, uns= igned int bus, @@ -1177,9 +1199,14 @@ int libxl_device_pci_add(libxl_ctx *ctx, uint32_t do= mid, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); - int rc; - rc =3D libxl__device_pci_add(gc, domid, pcidev, false); - libxl__ao_complete(egc, ao, rc); + libxl__ao_device *aodev; + + GCNEW(aodev); + libxl__prepare_ao_device(ao, aodev); + aodev->action =3D LIBXL__DEVICE_ACTION_ADD; + aodev->callback =3D device_addrm_aocomplete; + aodev->update_json =3D true; + libxl__device_pci_add(egc, domid, pcidev, false, aodev); return AO_INPROGRESS; } =20 @@ -1200,14 +1227,31 @@ static int libxl_pcidev_assignable(libxl_ctx *ctx, = libxl_device_pci *pcidev) return i !=3D num; } =20 -int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, - libxl_device_pci *pcidev, bool starting) +static void device_pci_add_stubdom_done(libxl__egc *egc, + pci_add_state *, int rc); +static void device_pci_add_done(libxl__egc *egc, + pci_add_state *, int rc); + +void libxl__device_pci_add(libxl__egc *egc, uint32_t domid, + libxl_device_pci *pcidev, bool starting, + libxl__ao_device *aodev) { + STATE_AO_GC(aodev->ao); libxl_ctx *ctx =3D libxl__gc_owner(gc); - unsigned int orig_vdev, pfunc_mask; libxl_device_pci *assigned; - int num_assigned, i, rc; + int num_assigned, rc; int stubdomid =3D 0; + pci_add_state *pas; + + /* Store *pcidev to be used by callbacks */ + aodev->device_config =3D pcidev; + aodev->device_type =3D &libxl__pcidev_devtype; + + GCNEW(pas); + pas->aodev =3D aodev; + pas->domid =3D domid; + pas->starting =3D starting; + pas->callback =3D device_pci_add_stubdom_done; =20 if (libxl__domain_type(gc, domid) =3D=3D LIBXL_DOMAIN_TYPE_HVM) { rc =3D xc_test_assign_device(ctx->xch, domid, pcidev_encode_bdf(pc= idev)); @@ -1254,13 +1298,39 @@ int libxl__device_pci_add(libxl__gc *gc, uint32_t d= omid, =20 stubdomid =3D libxl_get_stubdom_id(ctx, domid); if (stubdomid !=3D 0) { - libxl_device_pci pcidev_s =3D *pcidev; + libxl_device_pci *pcidev_s; + + GCNEW(pcidev_s); + libxl_device_pci_init(pcidev_s); + libxl_device_pci_copy(CTX, pcidev_s, pcidev); /* stubdomain is always running by now, even at create time */ - rc =3D do_pci_add(gc, stubdomid, &pcidev_s, false); - if ( rc ) - goto out; + pas->callback =3D device_pci_add_stubdom_done; + do_pci_add(egc, stubdomid, pcidev_s, pas); /* must be last */ + return; } =20 + device_pci_add_stubdom_done(egc, pas, 0); /* must be last */ + return; + +out: + device_pci_add_done(egc, pas, rc); /* must be last */ +} + +static void device_pci_add_stubdom_done(libxl__egc *egc, + pci_add_state *pas, + int rc) +{ + STATE_AO_GC(pas->aodev->ao); + unsigned int orig_vdev, pfunc_mask; + int i; + + /* Convenience aliases */ + libxl__ao_device *aodev =3D pas->aodev; + libxl_domid domid =3D pas->domid; + libxl_device_pci *pcidev =3D aodev->device_config; + + if (rc) goto out; + orig_vdev =3D pcidev->vdevfn & ~7U; =20 if ( pcidev->vfunc_mask =3D=3D LIBXL_PCI_FUNC_ALL ) { @@ -1291,31 +1361,83 @@ int libxl__device_pci_add(libxl__gc *gc, uint32_t d= omid, */ pcidev->vdevfn =3D orig_vdev; } - if ( do_pci_add(gc, domid, pcidev, starting) ) - rc =3D ERROR_FAIL; + pas->callback =3D device_pci_add_done; + do_pci_add(egc, domid, pcidev, pas); /* must be last */ + return; } } =20 out: - return rc; + device_pci_add_done(egc, pas, rc); +} + +static void device_pci_add_done(libxl__egc *egc, + pci_add_state *pas, + int rc) +{ + EGC_GC; + libxl__ao_device *aodev =3D pas->aodev; + libxl_domid domid =3D pas->domid; + libxl_device_pci *pcidev =3D aodev->device_config; + + if (rc) { + LOGD(ERROR, domid, + "libxl__device_pci_add failed for " + "PCI device %x:%x:%x.%x (rc %d)", + pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func, + rc); + } + aodev->rc =3D rc; + aodev->callback(egc, aodev); } =20 +typedef struct { + libxl__multidev multidev; + libxl__ao_device *outer_aodev; + libxl_domain_config *d_config; + libxl_domid domid; +} add_pcidevs_state; + +static void add_pcidevs_done(libxl__egc *, libxl__multidev *, int rc); + static void libxl__add_pcidevs(libxl__egc *egc, libxl__ao *ao, uint32_t do= mid, libxl_domain_config *d_config, libxl__multidev *multidev) { AO_GC; - libxl__ao_device *aodev =3D libxl__multidev_prepare(multidev); - int i, rc =3D 0; + add_pcidevs_state *apds; + int i; + + /* We need to start a new multidev in order to be able to execute + * libxl__create_pci_backend only once. */ + + GCNEW(apds); + apds->outer_aodev =3D libxl__multidev_prepare(multidev); + apds->d_config =3D d_config; + apds->domid =3D domid; + apds->multidev.callback =3D add_pcidevs_done; + libxl__multidev_begin(ao, &apds->multidev); =20 for (i =3D 0; i < d_config->num_pcidevs; i++) { - rc =3D libxl__device_pci_add(gc, domid, &d_config->pcidevs[i], tru= e); - if (rc < 0) { - LOGD(ERROR, domid, "libxl_device_pci_add failed: %d", rc); - goto out; - } + libxl__ao_device *aodev =3D libxl__multidev_prepare(&apds->multide= v); + libxl__device_pci_add(egc, domid, &d_config->pcidevs[i], + true, aodev); } =20 + libxl__multidev_prepared(egc, &apds->multidev, 0); +} + +static void add_pcidevs_done(libxl__egc *egc, libxl__multidev *multidev, + int rc) +{ + EGC_GC; + add_pcidevs_state *apds =3D CONTAINER_OF(multidev, *apds, multidev); + + /* Convenience aliases */ + libxl_domain_config *d_config =3D apds->d_config; + libxl_domid domid =3D apds->domid; + libxl__ao_device *aodev =3D apds->outer_aodev; + if (d_config->num_pcidevs > 0) { rc =3D libxl__create_pci_backend(gc, domid, d_config->pcidevs, d_config->num_pcidevs); --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761535; cv=none; d=zoho.com; s=zohoarc; b=ExP2RNoRxpMoW8J4q1Po3reIg2LxpmJ4NygHQb9aTJygS01BssMZewJW1Ybl7s/WeOj0/5TJyBRBDY4YqcVwCwRC8C2mkXCRGS2mhiGpPIxf574Jot7vUJikm8Ipq0uD2vA4S7QNoPQhcnbQ/yk6Cabkg1ly9o7wyAkjUQJK4Dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761535; 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=S96xjqAmqG557K8m7oxW0VJhs52OnH3QXDkddl1Dy1A=; b=I88DOidffEr+KvTLg51mVuRAacjYFQloeHRSwsUZg3ESytHKM2EagbxzYYBjNGEIvJ7HwHeJxYl0otNsgxaaZKV6SAqzw/NHktA0c74qxWjLL3g8IVFypyQnrwL/e26MMXZxXzWWqZClYb9Es8womhP245rUfRjWZ83CPdtwBTY= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761535799429.5301640163458; Fri, 2 Aug 2019 08:58:55 -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 1htZwk-0006G0-Pt; Fri, 02 Aug 2019 15:58:22 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwi-0006AN-6m for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:20 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5784d0f8-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:58:17 +0000 (UTC) X-Inumbo-ID: 5784d0f8-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: M9oMceXj7vBExvf/ooJQ0YtkC+NKuIB339bDPGQuVersbVgQCMtzA1QTPMftsf3MpNCB9zf25v dom3nLaxRJNAHCL9AOJvRqmqPjAMKqf0ojox/pC4y8uDPb807toro67+0U8quIydV2QAZCd5Lx lLld6WsFfsxZIOtx4esqCkyiB0C8vRl6a+QFmchgcPNGP0GexwxQhJrdptH5YJ9OWgczEEbsy7 L+w9Azm2aYeDSOxCRYkh0jVHToUnzaLaaUO/T1S6RVxboHcPwnRiWC1nMThBO57JsWCmYF3fT8 qFg= X-SBRS: 2.7 X-MesageID: 3787841 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3787841" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:35:59 +0100 Message-ID: <20190802153606.32061-29-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 28/35] libxl_pci: Use ev_qmp in do_pci_add 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" This patch also replaces the use of libxl__wait_for_device_model_deprecated() by its equivalent without the need for a thread. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_internal.h | 1 - tools/libxl/libxl_pci.c | 288 ++++++++++++++++++++++++++++++++--- tools/libxl/libxl_qmp.c | 96 ------------ 3 files changed, 265 insertions(+), 120 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index dd9934141f..277e322e09 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1981,7 +1981,6 @@ typedef struct libxl__qmp_handler libxl__qmp_handler; */ _hidden libxl__qmp_handler *libxl__qmp_initialize(libxl__gc *gc, uint32_t domid); -_hidden int libxl__qmp_pci_add(libxl__gc *gc, int d, libxl_device_pci *pci= dev); _hidden int libxl__qmp_pci_del(libxl__gc *gc, int domid, libxl_device_pci *pcidev); /* Resume hvm domain */ diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 503db6c260..3477f3aba6 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -23,6 +23,7 @@ #define PCI_BDF_VDEVFN "%04x:%02x:%02x.%01x@%02x" #define PCI_OPTIONS "msitranslate=3D%d,power_mgmt=3D%d" #define PCI_BDF_XSPATH "%04x-%02x-%02x-%01x" +#define PCI_PT_QDEV_ID "pci-pt-%02x_%02x.%01x" =20 static unsigned int pcidev_encode_bdf(libxl_device_pci *pcidev) { @@ -991,33 +992,40 @@ typedef struct pci_add_state { void (*callback)(libxl__egc *, struct pci_add_state *, int rc); =20 /* private to do_pci_add */ + libxl__xswait_state xswait; + libxl__ev_qmp qmp; + libxl__ev_time timeout; libxl_device_pci *pcidev; int pci_domid; } pci_add_state; =20 +static void pci_add_qemu_trad_watch_state_cb(libxl__egc *egc, + libxl__xswait_state *xswa, int rc, const char *state); +static void pci_add_qmp_device_add(libxl__egc *, pci_add_state *); +static void pci_add_qmp_device_add_cb(libxl__egc *, + libxl__ev_qmp *, const libxl__json_object *, int rc); +static void pci_add_qmp_query_pci_cb(libxl__egc *, + libxl__ev_qmp *, const libxl__json_object *, int rc); +static void pci_add_timeout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, int rc); +static void pci_add_dm_done(libxl__egc *, + pci_add_state *, int rc); + static void do_pci_add(libxl__egc *egc, libxl_domid domid, libxl_device_pci *pcidev, pci_add_state *pas) { STATE_AO_GC(pas->aodev->ao); - libxl_ctx *ctx =3D libxl__gc_owner(gc); libxl_domain_type type =3D libxl__domain_type(gc, domid); - char *sysfs_path; - FILE *f; - unsigned long long start, end, flags, size; - int irq, i, rc, hvm =3D 0; - uint32_t flag =3D XEN_DOMCTL_DEV_RDM_RELAXED; - uint32_t domainid =3D domid; - bool isstubdom =3D libxl_is_stubdom(ctx, domid, &domainid); - int r; - - /* Convenience aliases */ - bool starting =3D pas->starting; + int rc; =20 /* init pci_add_state */ + libxl__xswait_init(&pas->xswait); + libxl__ev_qmp_init(&pas->qmp); pas->pcidev =3D pcidev; pas->pci_domid =3D domid; + libxl__ev_time_init(&pas->timeout); =20 if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) { rc =3D ERROR_FAIL; @@ -1025,26 +1033,259 @@ static void do_pci_add(libxl__egc *egc, } =20 if (type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { - hvm =3D 1; switch (libxl__device_model_version_running(gc, domid)) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: - if (libxl__wait_for_device_model_deprecated(gc, domid, - "running", NULL, NULL, NULL) < 0) { - rc =3D ERROR_FAIL; - goto out; - } - rc =3D qemu_pci_add_xenstore(gc, domid, pcidev); - break; + pas->xswait.ao =3D ao; + pas->xswait.what =3D "Device Model"; + pas->xswait.path =3D DEVICE_MODEL_XS_PATH(gc, + libxl_get_stubdom_id(CTX, domid), domid, "/state"); + pas->xswait.timeout_ms =3D LIBXL_DEVICE_MODEL_START_TIMEOU= T * 1000; + pas->xswait.callback =3D pci_add_qemu_trad_watch_state_cb; + rc =3D libxl__xswait_start(gc, &pas->xswait); + if (rc) goto out; + return; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - rc =3D libxl__qmp_pci_add(gc, domid, pcidev); - break; + pci_add_qmp_device_add(egc, pas); /* must be last */ + return; default: rc =3D ERROR_INVAL; + break; } - if ( rc ) + } + + rc =3D 0; + +out: + pci_add_dm_done(egc, pas, rc); /* must be last */ +} + +static void pci_add_qemu_trad_watch_state_cb(libxl__egc *egc, + libxl__xswait_state *xswa, + int rc, + const char *state) +{ + pci_add_state *pas =3D CONTAINER_OF(xswa, *pas, xswait); + STATE_AO_GC(pas->aodev->ao); + + /* Convenience aliases */ + libxl_domid domid =3D pas->domid; + libxl_device_pci *pcidev =3D pas->pcidev; + + 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")) + return; + + 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 */ +} + +static void pci_add_qmp_device_add(libxl__egc *egc, pci_add_state *pas) +{ + STATE_AO_GC(pas->aodev->ao); + libxl__json_object *args =3D NULL; + int rc; + + /* Convenience aliases */ + libxl_domid domid =3D pas->domid; + libxl_device_pci *pcidev =3D pas->pcidev; + libxl__ev_qmp *const qmp =3D &pas->qmp; + + rc =3D libxl__ev_time_register_rel(ao, &pas->timeout, + pci_add_timeout, + LIBXL_QMP_CMD_TIMEOUT * 1000); + if (rc) goto out; + + libxl__qmp_param_add_string(gc, &args, "driver", + "xen-pci-passthrough"); + QMP_PARAMETERS_SPRINTF(&args, "id", PCI_PT_QDEV_ID, + pcidev->bus, pcidev->dev, pcidev->func); + QMP_PARAMETERS_SPRINTF(&args, "hostaddr", + "%04x:%02x:%02x.%01x", pcidev->domain, + pcidev->bus, pcidev->dev, pcidev->func); + if (pcidev->vdevfn) { + QMP_PARAMETERS_SPRINTF(&args, "addr", "%x.%x", + PCI_SLOT(pcidev->vdevfn), + PCI_FUNC(pcidev->vdevfn)); + } + /* + * Version of QEMU prior to the XSA-131 fix did not support + * this property and were effectively always in permissive + * mode. The fix for XSA-131 switched the default to be + * restricted by default and added the permissive property. + * + * Therefore in order to support both old and new QEMU we only + * set the permissive flag if it is true. Users of older QEMU + * have no reason to set the flag so this is ok. + */ + if (pcidev->permissive) + libxl__qmp_param_add_bool(gc, &args, "permissive", true); + + qmp->ao =3D pas->aodev->ao; + qmp->domid =3D domid; + qmp->payload_fd =3D -1; + qmp->callback =3D pci_add_qmp_device_add_cb; + rc =3D libxl__ev_qmp_send(gc, qmp, "device_add", args); + if (rc) goto out; + return; + +out: + pci_add_dm_done(egc, pas, rc); /* must be last */ +} + +static void pci_add_qmp_device_add_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + EGC_GC; + pci_add_state *pas =3D CONTAINER_OF(qmp, *pas, qmp); + + if (rc) goto out; + + qmp->callback =3D pci_add_qmp_query_pci_cb; + rc =3D libxl__ev_qmp_send(gc, qmp, "query-pci", NULL); + if (rc) goto out; + return; + +out: + pci_add_dm_done(egc, pas, rc); /* must be last */ +} + +static void pci_add_qmp_query_pci_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + EGC_GC; + pci_add_state *pas =3D CONTAINER_OF(qmp, *pas, qmp); + const libxl__json_object *bus =3D NULL; + char *asked_id; + int i, j; + const libxl__json_object *devices =3D NULL; + const libxl__json_object *device =3D NULL; + const libxl__json_object *o =3D NULL; + const char *id =3D NULL; + int dev_slot, dev_func; + + /* Convenience aliases */ + libxl_device_pci *pcidev =3D pas->pcidev; + + if (rc) goto out; + + /* `query-pci' returns: + * [ + * {'bus': 'int', + * 'devices': [ + * {'bus': 'int', 'slot': 'int', 'function': 'int', + * 'class_info': 'PciDeviceClass', 'id': 'PciDeviceId', + * '*irq': 'int', 'qdev_id': 'str', + * '*pci_bridge': 'PciBridgeInfo', + * 'regions': ['PciMemoryRegion'] + * } + * ] + * } + * ] + * (See qemu.git/qapi/ for the struct that aren't detailed here) + */ + + asked_id =3D GCSPRINTF(PCI_PT_QDEV_ID, + pcidev->bus, pcidev->dev, pcidev->func); + + for (i =3D 0; (bus =3D libxl__json_array_get(response, i)); i++) { + devices =3D libxl__json_map_get("devices", bus, JSON_ARRAY); + if (!devices) { + rc =3D ERROR_QEMU_API; goto out; + } + + for (j =3D 0; (device =3D libxl__json_array_get(devices, j)); j++)= { + o =3D libxl__json_map_get("qdev_id", device, JSON_STRING); + if (!o) { + rc =3D ERROR_QEMU_API; + goto out; + } + id =3D libxl__json_object_get_string(o); + if (!id || strcmp(asked_id, id)) + continue; + + o =3D libxl__json_map_get("slot", device, JSON_INTEGER); + if (!o) { + rc =3D ERROR_QEMU_API; + goto out; + } + dev_slot =3D libxl__json_object_get_integer(o); + o =3D libxl__json_map_get("function", device, JSON_INTEGER); + if (!o) { + rc =3D ERROR_QEMU_API; + goto out; + } + dev_func =3D libxl__json_object_get_integer(o); + + pcidev->vdevfn =3D PCI_DEVFN(dev_slot, dev_func); + + rc =3D 0; + goto out; + } } =20 + rc =3D ERROR_FAIL; + LOGD(ERROR, qmp->domid, + "PCI device id '%s' wasn't found in QEMU's 'query-pci' response.", + asked_id); + +out: + if (rc =3D=3D ERROR_QEMU_API) { + LOGD(ERROR, qmp->domid, + "Unexpected response to QMP cmd 'query-pci', received:\n%s", + JSON(response)); + } + pci_add_dm_done(egc, pas, rc); /* must be last */ +} + +static void pci_add_timeout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc) +{ + pci_add_state *pas =3D CONTAINER_OF(ev, *pas, timeout); + + pci_add_dm_done(egc, pas, rc); +} + +static void pci_add_dm_done(libxl__egc *egc, + pci_add_state *pas, + int rc) +{ + STATE_AO_GC(pas->aodev->ao); + libxl_ctx *ctx =3D libxl__gc_owner(gc); + libxl_domid domid =3D pas->pci_domid; + char *sysfs_path; + FILE *f; + unsigned long long start, end, flags, size; + int irq, i; + int r; + uint32_t flag =3D XEN_DOMCTL_DEV_RDM_RELAXED; + uint32_t domainid =3D domid; + bool isstubdom =3D libxl_is_stubdom(ctx, domid, &domainid); + + /* Convenience aliases */ + bool starting =3D pas->starting; + libxl_device_pci *pcidev =3D pas->pcidev; + bool hvm =3D libxl__domain_type(gc, domid) =3D=3D LIBXL_DOMAIN_TYPE_HV= M; + + libxl__ev_qmp_dispose(gc, &pas->qmp); + + if (rc) goto out; + sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource", pcidev->d= omain, pcidev->bus, pcidev->dev, pcidev->func); f =3D fopen(sysfs_path, "r"); @@ -1145,6 +1386,7 @@ static void do_pci_add(libxl__egc *egc, else rc =3D 0; out: + libxl__ev_time_deregister(gc, &pas->timeout); pas->callback(egc, pas, rc); } =20 diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index c78ef4637d..38ba63d5b9 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -736,54 +736,6 @@ void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid) } } =20 -static int pci_add_callback(libxl__qmp_handler *qmp, - const libxl__json_object *response, void *opaq= ue) -{ - libxl_device_pci *pcidev =3D opaque; - const libxl__json_object *bus =3D NULL; - GC_INIT(qmp->ctx); - int i, j, rc =3D -1; - char *asked_id =3D GCSPRINTF(PCI_PT_QDEV_ID, - pcidev->bus, pcidev->dev, pcidev->func); - - for (i =3D 0; (bus =3D libxl__json_array_get(response, i)); i++) { - const libxl__json_object *devices =3D NULL; - const libxl__json_object *device =3D NULL; - const libxl__json_object *o =3D NULL; - const char *id =3D NULL; - - devices =3D libxl__json_map_get("devices", bus, JSON_ARRAY); - - for (j =3D 0; (device =3D libxl__json_array_get(devices, j)); j++)= { - o =3D libxl__json_map_get("qdev_id", device, JSON_STRING); - id =3D libxl__json_object_get_string(o); - - if (id && strcmp(asked_id, id) =3D=3D 0) { - int dev_slot, dev_func; - - o =3D libxl__json_map_get("slot", device, JSON_INTEGER); - if (!o) - goto out; - dev_slot =3D libxl__json_object_get_integer(o); - o =3D libxl__json_map_get("function", device, JSON_INTEGE= R); - if (!o) - goto out; - dev_func =3D libxl__json_object_get_integer(o); - - pcidev->vdevfn =3D PCI_DEVFN(dev_slot, dev_func); - - rc =3D 0; - goto out; - } - } - } - - -out: - GC_FREE; - return rc; -} - static int pci_del_callback(libxl__qmp_handler *qmp, const libxl__json_object *response, void *opaq= ue) { @@ -833,54 +785,6 @@ static int qmp_run_command(libxl__gc *gc, int domid, return rc; } =20 -int libxl__qmp_pci_add(libxl__gc *gc, int domid, libxl_device_pci *pcidev) -{ - libxl__qmp_handler *qmp =3D NULL; - libxl__json_object *args =3D NULL; - char *hostaddr =3D NULL; - int rc =3D 0; - - qmp =3D libxl__qmp_initialize(gc, domid); - if (!qmp) - return -1; - - hostaddr =3D GCSPRINTF("%04x:%02x:%02x.%01x", pcidev->domain, - pcidev->bus, pcidev->dev, pcidev->func); - if (!hostaddr) - return -1; - - libxl__qmp_param_add_string(gc, &args, "driver", "xen-pci-passthrough"= ); - QMP_PARAMETERS_SPRINTF(&args, "id", PCI_PT_QDEV_ID, - pcidev->bus, pcidev->dev, pcidev->func); - libxl__qmp_param_add_string(gc, &args, "hostaddr", hostaddr); - if (pcidev->vdevfn) { - QMP_PARAMETERS_SPRINTF(&args, "addr", "%x.%x", - PCI_SLOT(pcidev->vdevfn), PCI_FUNC(pcidev->= vdevfn)); - } - /* - * Version of QEMU prior to the XSA-131 fix did not support this - * property and were effectively always in permissive mode. The - * fix for XSA-131 switched the default to be restricted by - * default and added the permissive property. - * - * Therefore in order to support both old and new QEMU we only set - * the permissive flag if it is true. Users of older QEMU have no - * reason to set the flag so this is ok. - */ - if (pcidev->permissive) - libxl__qmp_param_add_bool(gc, &args, "permissive", true); - - rc =3D qmp_synchronous_send(qmp, "device_add", args, - NULL, NULL, qmp->timeout); - if (rc =3D=3D 0) { - rc =3D qmp_synchronous_send(qmp, "query-pci", NULL, - pci_add_callback, pcidev, qmp->timeout); - } - - libxl__qmp_close(qmp); - return rc; -} - static int qmp_device_del(libxl__gc *gc, int domid, char *id) { libxl__json_object *args =3D NULL; --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761561; cv=none; d=zoho.com; s=zohoarc; b=P0hhF9asIPIYxZpbE3C32wz/yha4bSvA5oQTJN9pTW7dmVAHW3F9rGUOD3fu43ejqLxsb8hVF2cFrXWY84TVhso1NWOBHNwBVWDhKCP7JgMrpV8qgD1csbUawYCHRSruOeJJdUUuZvATlake1cTPj8ppHoGqfjgOU5M38qQpUfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761561; 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=mkKeiZAXC82nLvhtRWBWWL7gYM8BoaCMzDa3xmbpPVo=; b=DVYhBL5KQ77EHyEy5yGRF0Srgsfbb+xpxMYI/oGo/vSi8KrC6x6LQzrvErbZavwK96VhCpMVkdwKhDx2LU6GuL8KtSeT/e2T3wqukhIb1uayGGnEydTIjpPjD43RwbzPoysG7ClhPo4Pg70wiXy9RwQvhBYM8eJ+T9AkAoULqwg= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761561314790.8356218696197; Fri, 2 Aug 2019 08:59:21 -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 1htZwX-0005xT-ES; Fri, 02 Aug 2019 15:58:09 +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 1htZwV-0005vs-JV for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:07 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4f42198a-b53e-11e9-9f66-bfeb907b07a4; Fri, 02 Aug 2019 15:58:03 +0000 (UTC) X-Inumbo-ID: 4f42198a-b53e-11e9-9f66-bfeb907b07a4 Authentication-Results: esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: N/1+5RGIHt0R9CTfuy+zTQP3BJ3FEFis3qiIUWqOhgv6OV/26UgNFtt2Qx1NmGDoW3/TIscFWu GE92YkzOD8jPL23D/h9HuJPpGav+VZfEtzW2zLyzIg0uMNQ34Y8UlxCdXS/MokZcO2VyJBl+/L 8BRRvezczTpw6mXJUHl9LIIMPgWHzwe1nkTjQYbSRaPDcpPWd2ZbZkze7jEV+vuyfH1HNgMYm5 /aPizX/a+7u6JcjhKfZIPfPC2NTgK0xbXeRgPUISfjU2JpzaGIzM4BpqCLP1UszF016hq0p7pH Etc= X-SBRS: 2.7 X-MesageID: 3931669 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3931669" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:36:00 +0100 Message-ID: <20190802153606.32061-30-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 29/35] libxl_pci: Use libxl__ao_device with pci_remove 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" This is in preparation of using asynchronous operation to communicate with QEMU via QMP (libxl__ev_qmp). Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_domain.c | 49 ++++++-- tools/libxl/libxl_internal.h | 6 +- tools/libxl/libxl_pci.c | 221 ++++++++++++++++++++++++++--------- 3 files changed, 210 insertions(+), 66 deletions(-) diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index f3c39fa86f..cd71900350 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1104,6 +1104,9 @@ static void destroy_finish_check(libxl__egc *egc, } =20 /* Callbacks for libxl__destroy_domid */ +static void destroy_domid_pci_done(libxl__egc *egc, + libxl__multidev *multidev, + int rc); static void dm_destroy_cb(libxl__egc *egc, libxl__destroy_devicemodel_state *ddms, int rc); @@ -1120,8 +1123,7 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__des= troy_domid_state *dis) { STATE_AO_GC(dis->ao); uint32_t domid =3D dis->domid; - int rc, dm_present; - int r; + int rc; =20 libxl__ev_child_init(&dis->destroyer); =20 @@ -1135,6 +1137,41 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__de= stroy_domid_state *dis) goto out; } =20 + libxl__multidev_begin(ao, &dis->multidev); + dis->multidev.callback =3D destroy_domid_pci_done; + libxl__device_pci_destroy_all(egc, domid, &dis->multidev); + libxl__multidev_prepared(egc, &dis->multidev, 0); + return; + +out: + assert(rc); + dis->callback(egc, dis, rc); +} + +static void destroy_domid_pci_done(libxl__egc *egc, + libxl__multidev *multidev, + int rc) +{ + STATE_AO_GC(multidev->ao); + libxl__destroy_domid_state *dis =3D + CONTAINER_OF(multidev, *dis, multidev); + int dm_present; + int r; + + /* Convenience aliases */ + libxl_domid domid =3D dis->domid; + + if (rc) { + LOGD(ERROR, domid, "Pci shutdown failed"); + goto out; + } + + r =3D xc_domain_pause(CTX->xch, domid); + if (r < 0) { + LOGEVD(ERROR, r, domid, "xc_domain_pause failed"); + rc =3D ERROR_FAIL; + } + switch (libxl__domain_type(gc, domid)) { case LIBXL_DOMAIN_TYPE_HVM: if (libxl_get_stubdom_id(CTX, domid)) { @@ -1153,14 +1190,6 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__de= stroy_domid_state *dis) abort(); } =20 - if (libxl__device_pci_destroy_all(gc, domid) < 0) - LOGD(ERROR, domid, "Pci shutdown failed"); - r =3D xc_domain_pause(CTX->xch, domid); - if (r < 0) { - LOGEVD(ERROR, r, domid, "xc_domain_pause failed"); - rc =3D ERROR_FAIL; - } - if (dm_present) { dis->ddms.ao =3D ao; dis->ddms.domid =3D domid; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 277e322e09..ca3d3c7090 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -199,6 +199,7 @@ typedef struct libxl__carefd libxl__carefd; typedef struct libxl__ev_lock libxl__ev_lock; typedef struct libxl__dm_resume_state libxl__dm_resume_state; typedef struct libxl__ao_device libxl__ao_device; +typedef struct libxl__multidev libxl__multidev; =20 typedef struct libxl__domain_create_state libxl__domain_create_state; typedef void libxl__domain_create_cb(struct libxl__egc *egc, @@ -1596,7 +1597,8 @@ _hidden int libxl__pci_topology_init(libxl__gc *gc, _hidden void libxl__device_pci_add(libxl__egc *egc, uint32_t domid, libxl_device_pci *pcidev, bool starting, libxl__ao_device *aodev); -_hidden int libxl__device_pci_destroy_all(libxl__gc *gc, uint32_t domid); +_hidden void libxl__device_pci_destroy_all(libxl__egc *egc, uint32_t domid, + libxl__multidev *); _hidden bool libxl__is_igd_vga_passthru(libxl__gc *gc, const libxl_domain_config *d_confi= g); =20 @@ -2572,7 +2574,6 @@ _hidden void libxl__kill(libxl__gc *gc, pid_t pid, in= t sig, const char *what); =20 /*----- device addition/removal -----*/ =20 -typedef struct libxl__multidev libxl__multidev; typedef void libxl__device_callback(libxl__egc*, libxl__ao_device*); =20 /* This functions sets the necessary libxl__ao_device struct values to use @@ -3919,6 +3920,7 @@ struct libxl__destroy_domid_state { libxl__destroy_devicemodel_state ddms; libxl__ev_child destroyer; bool soft_reset; + libxl__multidev multidev; }; =20 struct libxl__domain_destroy_state { diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 3477f3aba6..a5f700f0bf 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -1730,24 +1730,47 @@ static int qemu_pci_remove_xenstore(libxl__gc *gc, = uint32_t domid, return 0; } =20 -static int libxl__device_pci_remove_common(libxl__gc *gc, uint32_t domid, - libxl_device_pci *pcidev, int f= orce); - -static int do_pci_remove(libxl__gc *gc, uint32_t domid, - libxl_device_pci *pcidev, int force) +typedef struct pci_remove_state { + libxl__ao_device *aodev; + libxl_domid domid; + libxl_device_pci *pcidev; + bool force; + bool hvm; + unsigned int orig_vdev; + unsigned int pfunc_mask; + int next_func; + libxl__ao_device stubdom_aodev; +} pci_remove_state; + +static void libxl__device_pci_remove_common(libxl__egc *egc, + uint32_t domid, libxl_device_pci *pcidev, bool force, + libxl__ao_device *aodev); +static void device_pci_remove_common_next(libxl__egc *egc, + pci_remove_state *prs, int rc); +static void pci_remove_detatched(libxl__egc *egc, + pci_remove_state *prs, int rc); +static void pci_remove_stubdom_done(libxl__egc *egc, + libxl__ao_device *aodev); +static void pci_remove_done(libxl__egc *egc, + pci_remove_state *prs, int rc); + +static void do_pci_remove(libxl__egc *egc, uint32_t domid, + libxl_device_pci *pcidev, int force, + pci_remove_state *prs) { + STATE_AO_GC(prs->aodev->ao); libxl_ctx *ctx =3D libxl__gc_owner(gc); libxl_device_pci *assigned; libxl_domain_type type =3D libxl__domain_type(gc, domid); - int hvm =3D 0, rc, num; - int stubdomid =3D 0; + int rc, num; uint32_t domainid =3D domid; - bool isstubdom =3D libxl_is_stubdom(ctx, domid, &domainid); - =20 assigned =3D libxl_device_pci_list(ctx, domid, &num); - if ( assigned =3D=3D NULL ) - return ERROR_FAIL; + if (assigned =3D=3D NULL) { + rc =3D ERROR_FAIL; + goto out_fail; + } + libxl__ptr_add(gc, assigned); =20 rc =3D ERROR_INVAL; if ( !is_pcidev_in_array(assigned, num, pcidev->domain, @@ -1758,7 +1781,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domi= d, =20 rc =3D ERROR_FAIL; if (type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { - hvm =3D 1; + prs->hvm =3D true; switch (libxl__device_model_version_running(gc, domid)) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: if (libxl__wait_for_device_model_deprecated(gc, domid, @@ -1821,7 +1844,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domi= d, f =3D fopen(sysfs_path, "r"); if (f =3D=3D NULL) { LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path); - goto out; + goto skip_irq; } if ((fscanf(f, "%u", &irq) =3D=3D 1) && irq) { rc =3D xc_physdev_unmap_pirq(ctx->xch, domid, irq); @@ -1835,52 +1858,134 @@ static int do_pci_remove(libxl__gc *gc, uint32_t d= omid, } fclose(f); } -out: +skip_irq: + rc =3D 0; +out_fail: + pci_remove_detatched(egc, prs, rc); +} + +static void pci_remove_detatched(libxl__egc *egc, + pci_remove_state *prs, + int rc) +{ + STATE_AO_GC(prs->aodev->ao); + int stubdomid =3D 0; + uint32_t domainid =3D prs->domid; + bool isstubdom; + + /* Convenience aliases */ + libxl_device_pci *const pcidev =3D prs->pcidev; + libxl_domid domid =3D prs->domid; + + if (rc) goto out; + + isstubdom =3D libxl_is_stubdom(CTX, domid, &domainid); + /* don't do multiple resets while some functions are still passed thro= ugh */ if ( (pcidev->vdevfn & 0x7) =3D=3D 0 ) { libxl__device_pci_reset(gc, pcidev->domain, pcidev->bus, pcidev->d= ev, pcidev->func); } =20 if (!isstubdom) { - rc =3D xc_deassign_device(ctx->xch, domid, pcidev_encode_bdf(pcide= v)); - if (rc < 0 && (hvm || errno !=3D ENOSYS)) + rc =3D xc_deassign_device(CTX->xch, domid, pcidev_encode_bdf(pcide= v)); + if (rc < 0 && (prs->hvm || errno !=3D ENOSYS)) LOGED(ERROR, domainid, "xc_deassign_device failed"); } =20 - stubdomid =3D libxl_get_stubdom_id(ctx, domid); + stubdomid =3D libxl_get_stubdom_id(CTX, domid); if (stubdomid !=3D 0) { - libxl_device_pci pcidev_s =3D *pcidev; - libxl__device_pci_remove_common(gc, stubdomid, &pcidev_s, force); - } + libxl_device_pci *pcidev_s; + libxl__ao_device *const stubdom_aodev =3D &prs->stubdom_aodev; + + GCNEW(pcidev_s); + libxl_device_pci_init(pcidev_s); + libxl_device_pci_copy(CTX, pcidev_s, pcidev); =20 - libxl__device_pci_remove_xenstore(gc, domid, pcidev); + libxl__prepare_ao_device(ao, stubdom_aodev); + stubdom_aodev->action =3D LIBXL__DEVICE_ACTION_REMOVE; + stubdom_aodev->callback =3D pci_remove_stubdom_done; + stubdom_aodev->update_json =3D prs->aodev->update_json; + libxl__device_pci_remove_common(egc, stubdomid, pcidev_s, + prs->force, stubdom_aodev); + return; + } =20 rc =3D 0; -out_fail: - free(assigned); - return rc; +out: + pci_remove_done(egc, prs, rc); +} + +static void pci_remove_stubdom_done(libxl__egc *egc, + libxl__ao_device *aodev) +{ + pci_remove_state *prs =3D CONTAINER_OF(aodev, *prs, stubdom_aodev); =20 + pci_remove_done(egc, prs, 0); } =20 -static int libxl__device_pci_remove_common(libxl__gc *gc, uint32_t domid, - libxl_device_pci *pcidev, int f= orce) +static void pci_remove_done(libxl__egc *egc, + pci_remove_state *prs, + int rc) { - unsigned int orig_vdev, pfunc_mask; - int i, rc; + EGC_GC; =20 - orig_vdev =3D pcidev->vdevfn & ~7U; + if (rc) goto out; + + libxl__device_pci_remove_xenstore(gc, prs->domid, prs->pcidev); +out: + device_pci_remove_common_next(egc, prs, rc); +} + +static void libxl__device_pci_remove_common(libxl__egc *egc, + uint32_t domid, + libxl_device_pci *pcidev, + bool force, + libxl__ao_device *aodev) +{ + STATE_AO_GC(aodev->ao); + int rc; + pci_remove_state *prs; + + GCNEW(prs); + prs->aodev =3D aodev; + prs->domid =3D domid; + prs->pcidev =3D pcidev; + prs->force =3D force; + + prs->orig_vdev =3D pcidev->vdevfn & ~7U; =20 if ( pcidev->vfunc_mask =3D=3D LIBXL_PCI_FUNC_ALL ) { - if ( pci_multifunction_check(gc, pcidev, &pfunc_mask) ) { + if ( pci_multifunction_check(gc, pcidev, &prs->pfunc_mask) ) { rc =3D ERROR_FAIL; goto out; } - pcidev->vfunc_mask &=3D pfunc_mask; + pcidev->vfunc_mask &=3D prs->pfunc_mask; }else{ - pfunc_mask =3D (1 << pcidev->func); + prs->pfunc_mask =3D (1 << pcidev->func); } =20 - for(rc =3D 0, i =3D 7; i >=3D 0; --i) { + rc =3D 0; + prs->next_func =3D 7; +out: + device_pci_remove_common_next(egc, prs, rc); +} + +static void device_pci_remove_common_next(libxl__egc *egc, + pci_remove_state *prs, + int rc) +{ + /* Convenience aliases */ + libxl_domid domid =3D prs->domid; + libxl_device_pci *const pcidev =3D prs->pcidev; + libxl__ao_device *const aodev =3D prs->aodev; + const unsigned int pfunc_mask =3D prs->pfunc_mask; + const unsigned int orig_vdev =3D prs->orig_vdev; + + if (rc) goto out; + + while (prs->next_func >=3D 0) { + const int i =3D prs->next_func; + prs->next_func--; if ( (1 << i) & pfunc_mask ) { if ( pcidev->vfunc_mask =3D=3D pfunc_mask ) { pcidev->func =3D i; @@ -1888,13 +1993,15 @@ static int libxl__device_pci_remove_common(libxl__g= c *gc, uint32_t domid, }else{ pcidev->vdevfn =3D orig_vdev; } - if ( do_pci_remove(gc, domid, pcidev, force) ) - rc =3D ERROR_FAIL; + do_pci_remove(egc, domid, pcidev, prs->force, prs); + return; } } =20 + rc =3D 0; out: - return rc; + aodev->rc =3D rc; + aodev->callback(egc, aodev); } =20 int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid, @@ -1903,11 +2010,14 @@ int libxl_device_pci_remove(libxl_ctx *ctx, uint32_= t domid, =20 { AO_CREATE(ctx, domid, ao_how); - int rc; - - rc =3D libxl__device_pci_remove_common(gc, domid, pcidev, 0); + libxl__ao_device *aodev; =20 - libxl__ao_complete(egc, ao, rc); + GCNEW(aodev); + libxl__prepare_ao_device(ao, aodev); + aodev->action =3D LIBXL__DEVICE_ACTION_REMOVE; + aodev->callback =3D device_addrm_aocomplete; + aodev->update_json =3D true; + libxl__device_pci_remove_common(egc, domid, pcidev, false, aodev); return AO_INPROGRESS; } =20 @@ -1916,11 +2026,14 @@ int libxl_device_pci_destroy(libxl_ctx *ctx, uint32= _t domid, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); - int rc; - - rc =3D libxl__device_pci_remove_common(gc, domid, pcidev, 1); + libxl__ao_device *aodev; =20 - libxl__ao_complete(egc, ao, rc); + GCNEW(aodev); + libxl__prepare_ao_device(ao, aodev); + aodev->action =3D LIBXL__DEVICE_ACTION_REMOVE; + aodev->callback =3D device_addrm_aocomplete; + aodev->update_json =3D true; + libxl__device_pci_remove_common(egc, domid, pcidev, true, aodev); return AO_INPROGRESS; } =20 @@ -2004,27 +2117,27 @@ libxl_device_pci *libxl_device_pci_list(libxl_ctx *= ctx, uint32_t domid, int *num return pcidevs; } =20 -int libxl__device_pci_destroy_all(libxl__gc *gc, uint32_t domid) +void libxl__device_pci_destroy_all(libxl__egc *egc, uint32_t domid, + libxl__multidev *multidev) { - libxl_ctx *ctx =3D libxl__gc_owner(gc); + STATE_AO_GC(multidev->ao); libxl_device_pci *pcidevs; - int num, i, rc =3D 0; + int num, i; =20 - pcidevs =3D libxl_device_pci_list(ctx, domid, &num); + pcidevs =3D libxl_device_pci_list(CTX, domid, &num); if ( pcidevs =3D=3D NULL ) - return 0; + return; + libxl__ptr_add(gc, pcidevs); =20 for (i =3D 0; i < num; i++) { /* Force remove on shutdown since, on HVM, qemu will not always * respond to SCI interrupt because the guest kernel has shut down= the * devices by the time we even get here! */ - if (libxl__device_pci_remove_common(gc, domid, pcidevs + i, 1) < 0) - rc =3D ERROR_FAIL; + libxl__ao_device *aodev =3D libxl__multidev_prepare(multidev); + libxl__device_pci_remove_common(egc, domid, pcidevs + i, true, + aodev); } - - free(pcidevs); - return rc; } =20 int libxl__grant_vga_iomem_permission(libxl__gc *gc, const uint32_t domid, --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761542; cv=none; d=zoho.com; s=zohoarc; b=b1HN1AP9K5PWRlePxZ+w8TI410jkW7HBJYRHjc1IZMur1c9QLMbvfF1Qdeu+yHf4QHYmabQXjW1tsl6ZKzbWY17p1Gbt7s9/ElGucVaF9AtB/8rOTj3EYz9/ikK+tLUfRpkZfHlaMWlB1EFF4yyrZhxqfuHKaSyOfbff8ge4BT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761542; 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=rvglfkf/6rE1anOJ9/MC8M0qR47LW+VtXw9jgRb0wO8=; b=NAAaIe9K2r+fbGb9wy0+RRtpyN+IqgBLQJfgPWKaskTt135jQuLWLohxwVqMjR/dtDUKFEAspnMYz/9IiZExvKpjekHBWCK3D12vMBDFtP4P6uLNpPiCMBGIOY2yRbY/VqXu8xFWf5ggLvHh6TDmWu1r2p2KYFsUEDJxB5WfwRI= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761542866966.261030390492; Fri, 2 Aug 2019 08:59:02 -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 1htZwn-0006Kp-FP; Fri, 02 Aug 2019 15:58:25 +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 1htZwl-0006Hd-NF for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:23 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5a10cc76-b53e-11e9-b58a-734243b1be32; Fri, 02 Aug 2019 15:58:22 +0000 (UTC) X-Inumbo-ID: 5a10cc76-b53e-11e9-b58a-734243b1be32 Authentication-Results: esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: JqPNpPvZKuLmcup7YZzxGt53j9Zomfs4TauNqrxjrz3+CgjnlPCY4h1IA82EKX1hf1fLN9XMpV zE7FiE6tyLXw8mVdDcx9J5uSfqFNbhkGz4b8sBKvvoRTI22osV4CIYiLfAnKJ54zpXpzmoAIH5 Fgbz8iTskuyBu/LI2BH0/d4tt/LTF1mptGp1drnN/4/2fe+K7EGZ3o9vO8HPh/StwXKIrgjiUn hXPszKNQMe2+1Dh6al68z9yjyixUCegi5CPoUdw2WKRWOlNd+azQxhRFrBLxQ6Yh7dtNWBQ5wb 3RA= X-SBRS: 2.7 X-MesageID: 3931690 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3931690" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:36:01 +0100 Message-ID: <20190802153606.32061-31-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 30/35] libxl_pci: Use ev_qmp for pci_remove 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" This patch also replaces the use of libxl__wait_for_device_model_deprecated() by its equivalent without the need for a thread. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- Notes: In do_pci_remove, instead of using a poll loop { ev_timer ; query-pci }, it could be possible to listen to events sent by QEMU via QMP; in order to wait for the passthrough pci device to be removed from QEMU. (possible improvement) tools/libxl/libxl_internal.h | 2 - tools/libxl/libxl_pci.c | 219 +++++++++++++++++++++++++++++++++-- tools/libxl/libxl_qmp.c | 77 ------------ 3 files changed, 207 insertions(+), 91 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index ca3d3c7090..3e7cb4005d 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1983,8 +1983,6 @@ typedef struct libxl__qmp_handler libxl__qmp_handler; */ _hidden libxl__qmp_handler *libxl__qmp_initialize(libxl__gc *gc, uint32_t domid); -_hidden int libxl__qmp_pci_del(libxl__gc *gc, int domid, - libxl_device_pci *pcidev); /* Resume hvm domain */ _hidden int libxl__qmp_system_wakeup(libxl__gc *gc, int domid); /* Resume QEMU. */ diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index a5f700f0bf..c4ac677f3d 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -1740,6 +1740,10 @@ typedef struct pci_remove_state { unsigned int pfunc_mask; int next_func; libxl__ao_device stubdom_aodev; + libxl__xswait_state xswait; + libxl__ev_qmp qmp; + libxl__ev_time timeout; + libxl__ev_time retry_timer; } pci_remove_state; =20 static void libxl__device_pci_remove_common(libxl__egc *egc, @@ -1747,10 +1751,23 @@ static void libxl__device_pci_remove_common(libxl__= egc *egc, libxl__ao_device *aodev); static void device_pci_remove_common_next(libxl__egc *egc, pci_remove_state *prs, int rc); + +static void pci_remove_qemu_trad_watch_state_cb(libxl__egc *egc, + libxl__xswait_state *xswa, int rc, const char *state); +static void pci_remove_qmp_device_del(libxl__egc *egc, + pci_remove_state *prs); +static void pci_remove_qmp_device_del_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc); +static void pci_remove_qmp_retry_timer_cb(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc); +static void pci_remove_qmp_query_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc); static void pci_remove_detatched(libxl__egc *egc, pci_remove_state *prs, int rc); static void pci_remove_stubdom_done(libxl__egc *egc, libxl__ao_device *aodev); +static void pci_remove_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc); static void pci_remove_done(libxl__egc *egc, pci_remove_state *prs, int rc); =20 @@ -1784,22 +1801,22 @@ static void do_pci_remove(libxl__egc *egc, uint32_t= domid, prs->hvm =3D true; switch (libxl__device_model_version_running(gc, domid)) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: - if (libxl__wait_for_device_model_deprecated(gc, domid, - "running", NULL, NULL, NULL) < 0) - goto out_fail; - rc =3D qemu_pci_remove_xenstore(gc, domid, pcidev, force); - break; + prs->xswait.ao =3D ao; + prs->xswait.what =3D "Device Model"; + prs->xswait.path =3D DEVICE_MODEL_XS_PATH(gc, + libxl_get_stubdom_id(CTX, domid), domid, "/state"); + prs->xswait.timeout_ms =3D LIBXL_DEVICE_MODEL_START_TIMEOUT * = 1000; + prs->xswait.callback =3D pci_remove_qemu_trad_watch_state_cb; + rc =3D libxl__xswait_start(gc, &prs->xswait); + if (rc) goto out_fail; + return; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - rc =3D libxl__qmp_pci_del(gc, domid, pcidev); - break; + pci_remove_qmp_device_del(egc, prs); /* must be last */ + return; default: rc =3D ERROR_INVAL; goto out_fail; } - if (rc && !force) { - rc =3D ERROR_FAIL; - goto out_fail; - } } else { assert(type =3D=3D LIBXL_DOMAIN_TYPE_PV); =20 @@ -1861,9 +1878,160 @@ static void do_pci_remove(libxl__egc *egc, uint32_t= domid, skip_irq: rc =3D 0; out_fail: + pci_remove_detatched(egc, prs, rc); /* must be last */ +} + +static void pci_remove_qemu_trad_watch_state_cb(libxl__egc *egc, + libxl__xswait_state *xswa, + int rc, + const char *state) +{ + pci_remove_state *prs =3D CONTAINER_OF(xswa, *prs, xswait); + STATE_AO_GC(prs->aodev->ao); + + /* Convenience aliases */ + libxl_domid domid =3D prs->domid; + libxl_device_pci *const pcidev =3D prs->pcidev; + + 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")) + return; + + rc =3D qemu_pci_remove_xenstore(gc, domid, pcidev, prs->force); + +out: + libxl__xswait_stop(gc, xswa); pci_remove_detatched(egc, prs, rc); } =20 +static void pci_remove_qmp_device_del(libxl__egc *egc, + pci_remove_state *prs) +{ + STATE_AO_GC(prs->aodev->ao); + libxl__json_object *args =3D NULL; + int rc; + + /* Convenience aliases */ + libxl_device_pci *const pcidev =3D prs->pcidev; + + rc =3D libxl__ev_time_register_rel(ao, &prs->timeout, + pci_remove_timeout, + LIBXL_QMP_CMD_TIMEOUT * 1000); + if (rc) goto out; + + QMP_PARAMETERS_SPRINTF(&args, "id", PCI_PT_QDEV_ID, + pcidev->bus, pcidev->dev, pcidev->func); + prs->qmp.callback =3D pci_remove_qmp_device_del_cb; + rc =3D libxl__ev_qmp_send(gc, &prs->qmp, "device_del", args); + if (rc) goto out; + return; + +out: + pci_remove_detatched(egc, prs, rc); +} + +static void pci_remove_qmp_device_del_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *respons= e, + int rc) +{ + EGC_GC; + pci_remove_state *prs =3D CONTAINER_OF(qmp, *prs, qmp); + + if (rc) goto out; + + /* Now that the command is sent, we want to wait until QEMU has + * comfirmed that the device is removed. */ + pci_remove_qmp_retry_timer_cb(egc, &prs->retry_timer, NULL, + ERROR_TIMEDOUT); + return; + +out: + pci_remove_detatched(egc, prs, rc); +} + +static void pci_remove_qmp_retry_timer_cb(libxl__egc *egc, libxl__ev_time = *ev, + const struct timeval *requested_= abs, + int rc) +{ + EGC_GC; + pci_remove_state *prs =3D CONTAINER_OF(ev, *prs, retry_timer); + + prs->qmp.callback =3D pci_remove_qmp_query_cb; + rc =3D libxl__ev_qmp_send(gc, &prs->qmp, "query-pci", NULL); + if (rc) goto out; + return; + +out: + pci_remove_detatched(egc, prs, rc); +} + +static void pci_remove_qmp_query_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + EGC_GC; + pci_remove_state *prs =3D CONTAINER_OF(qmp, *prs, qmp); + const libxl__json_object *bus =3D NULL; + const char *asked_id; + int i, j; + + /* Convenience aliases */ + libxl__ao *const ao =3D prs->aodev->ao; + libxl_device_pci *const pcidev =3D prs->pcidev; + + if (rc) goto out; + + asked_id =3D GCSPRINTF(PCI_PT_QDEV_ID, + pcidev->bus, pcidev->dev, pcidev->func); + + /* query-pci response: + * [{ 'devices': [ 'qdev_id': 'str', ... ], ... }] + * */ + + for (i =3D 0; (bus =3D libxl__json_array_get(response, i)); i++) { + const libxl__json_object *devices =3D NULL; + const libxl__json_object *device =3D NULL; + const libxl__json_object *o =3D NULL; + const char *id =3D NULL; + + devices =3D libxl__json_map_get("devices", bus, JSON_ARRAY); + if (!devices) { + rc =3D ERROR_QEMU_API; + goto out; + } + + for (j =3D 0; (device =3D libxl__json_array_get(devices, j)); j++)= { + o =3D libxl__json_map_get("qdev_id", device, JSON_STRING); + if (!o) { + rc =3D ERROR_QEMU_API; + goto out; + } + id =3D libxl__json_object_get_string(o); + + if (id && !strcmp(asked_id, id)) { + /* Device still in QEMU, need to wait longuer. */ + rc =3D libxl__ev_time_register_rel(ao, &prs->retry_timer, + pci_remove_qmp_retry_timer_cb, 1000); + if (rc) goto out; + return; + } + } + } + +out: + pci_remove_detatched(egc, prs, rc); /* must be last */ +} + static void pci_remove_detatched(libxl__egc *egc, pci_remove_state *prs, int rc) @@ -1877,7 +2045,8 @@ static void pci_remove_detatched(libxl__egc *egc, libxl_device_pci *const pcidev =3D prs->pcidev; libxl_domid domid =3D prs->domid; =20 - if (rc) goto out; + if (rc && !prs->force) + goto out; =20 isstubdom =3D libxl_is_stubdom(CTX, domid, &domainid); =20 @@ -1923,6 +2092,15 @@ static void pci_remove_stubdom_done(libxl__egc *egc, pci_remove_done(egc, prs, 0); } =20 +static void pci_remove_timeout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc) +{ + pci_remove_state *prs =3D CONTAINER_OF(ev, *prs, timeout); + + pci_remove_done(egc, prs, rc); +} + static void pci_remove_done(libxl__egc *egc, pci_remove_state *prs, int rc) @@ -1931,6 +2109,10 @@ static void pci_remove_done(libxl__egc *egc, =20 if (rc) goto out; =20 + libxl__ev_qmp_dispose(gc, &prs->qmp); + libxl__ev_time_deregister(gc, &prs->timeout); + libxl__ev_time_deregister(gc, &prs->retry_timer); + libxl__device_pci_remove_xenstore(gc, prs->domid, prs->pcidev); out: device_pci_remove_common_next(egc, prs, rc); @@ -1951,6 +2133,13 @@ static void libxl__device_pci_remove_common(libxl__e= gc *egc, prs->domid =3D domid; prs->pcidev =3D pcidev; prs->force =3D force; + libxl__xswait_init(&prs->xswait); + libxl__ev_qmp_init(&prs->qmp); + prs->qmp.ao =3D prs->aodev->ao; + prs->qmp.domid =3D prs->domid; + prs->qmp.payload_fd =3D -1; + libxl__ev_time_init(&prs->timeout); + libxl__ev_time_init(&prs->retry_timer); =20 prs->orig_vdev =3D pcidev->vdevfn & ~7U; =20 @@ -1974,6 +2163,8 @@ static void device_pci_remove_common_next(libxl__egc = *egc, pci_remove_state *prs, int rc) { + EGC_GC; + /* Convenience aliases */ libxl_domid domid =3D prs->domid; libxl_device_pci *const pcidev =3D prs->pcidev; @@ -2000,6 +2191,10 @@ static void device_pci_remove_common_next(libxl__egc= *egc, =20 rc =3D 0; out: + libxl__ev_qmp_dispose(gc, &prs->qmp); + libxl__xswait_stop(gc, &prs->xswait); + libxl__ev_time_deregister(gc, &prs->timeout); + libxl__ev_time_deregister(gc, &prs->retry_timer); aodev->rc =3D rc; aodev->callback(egc, aodev); } diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 38ba63d5b9..8fac737fad 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -87,7 +87,6 @@ =20 #define QMP_RECEIVE_BUFFER_SIZE 4096 #define QMP_MAX_SIZE_RX_BUF MB(1) -#define PCI_PT_QDEV_ID "pci-pt-%02x_%02x.%01x" =20 /* * qmp_callback_t is call whenever a message from QMP contain the "id" @@ -736,38 +735,6 @@ void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid) } } =20 -static int pci_del_callback(libxl__qmp_handler *qmp, - const libxl__json_object *response, void *opaq= ue) -{ - const char *asked_id =3D opaque; - const libxl__json_object *bus =3D NULL; - GC_INIT(qmp->ctx); - int i, j, rc =3D 0; - - for (i =3D 0; (bus =3D libxl__json_array_get(response, i)); i++) { - const libxl__json_object *devices =3D NULL; - const libxl__json_object *device =3D NULL; - const libxl__json_object *o =3D NULL; - const char *id =3D NULL; - - devices =3D libxl__json_map_get("devices", bus, JSON_ARRAY); - - for (j =3D 0; (device =3D libxl__json_array_get(devices, j)); j++)= { - o =3D libxl__json_map_get("qdev_id", device, JSON_STRING); - id =3D libxl__json_object_get_string(o); - - if (id && strcmp(asked_id, id) =3D=3D 0) { - rc =3D 1; - goto out; - } - } - } - -out: - GC_FREE; - return rc; -} - static int qmp_run_command(libxl__gc *gc, int domid, const char *cmd, libxl__json_object *args, qmp_callback_t callback, void *opaque) @@ -785,50 +752,6 @@ static int qmp_run_command(libxl__gc *gc, int domid, return rc; } =20 -static int qmp_device_del(libxl__gc *gc, int domid, char *id) -{ - libxl__json_object *args =3D NULL; - libxl__qmp_handler *qmp =3D NULL; - int rc =3D 0; - - qmp =3D libxl__qmp_initialize(gc, domid); - if (!qmp) - return ERROR_FAIL; - - libxl__qmp_param_add_string(gc, &args, "id", id); - rc =3D qmp_synchronous_send(qmp, "device_del", args, - NULL, NULL, qmp->timeout); - if (rc =3D=3D 0) { - unsigned int retry =3D 0; - - do { - rc =3D qmp_synchronous_send(qmp, "query-pci", NULL, - pci_del_callback, id, qmp->timeout); - if (rc !=3D 1) { - break; - } - sleep(1); - } while (retry++ < 5); - - if (rc !=3D 0) { - LOGD(WARN, qmp->domid, - "device model may not complete removing device %s", id); - } - } - - libxl__qmp_close(qmp); - return rc; -} - -int libxl__qmp_pci_del(libxl__gc *gc, int domid, libxl_device_pci *pcidev) -{ - char *id =3D NULL; - - id =3D GCSPRINTF(PCI_PT_QDEV_ID, pcidev->bus, pcidev->dev, pcidev->fun= c); - - return qmp_device_del(gc, domid, id); -} - int libxl__qmp_system_wakeup(libxl__gc *gc, int domid) { return qmp_run_command(gc, domid, "system_wakeup", NULL, NULL, NULL); --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761546; cv=none; d=zoho.com; s=zohoarc; b=OoedcLiyG0svv+V+ebOLnQ6B+emDXXV4bkHmRJIympFiDU4Nii2jxUxi1H8ockCDI57m5589FK2qQBojgmABrZNvOrQEeiinmNq4LGcdVVQ4MraKdMUrLXJnRTlbXSSTn9GZWFUIxDeD+wvRJ7mkdhcjzMeCPNm47gQoCzjtBEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761546; 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=RXmjdhNHHbQsf+Aci2ilklez5WhCnd9RGhnX3obQbQg=; b=cd2/kTspwa8ZTRwPklA4m3RM56pImfZcfLuvSvrc8mQKswJcrCpDZZmaREBx5YWCk24jJ5Oxjkw6Em/ACFkA/I4pioMlQc29Fl5oh/AWKS0K/qOlizLYO3B/6LDWSmSyI+S530U+kh+8DjweXVjN3O5tOxYXOXNlBjh7SlrFEQc= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761546667686.2954400240011; Fri, 2 Aug 2019 08:59:06 -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 1htZwx-0006dV-T8; Fri, 02 Aug 2019 15:58:35 +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 1htZww-0006aH-1j for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:34 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 60d1086e-b53e-11e9-8f4b-ffbcaae814cf; Fri, 02 Aug 2019 15:58:32 +0000 (UTC) X-Inumbo-ID: 60d1086e-b53e-11e9-8f4b-ffbcaae814cf Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: xzcBt1ITsz0PlRLz7RLYxHuXGRC7tFnIqz5VT++3xWRx/laF06sl4wlnkVR2a1L9wah8J8Zy3s XPEa8+UdRDBM9zjQkHLUnJcpzz0gOyxywm75YmjopgzCN3H8o8CbVraZc9rh5kJvYPOjtgIV4B j+BAJXxY88PQg16bKELSa3Um0MCyRzE12PXYlTX/UFwZUf0Xp/+Rft3vsg5Wp/rP++bd8hBb51 NIf+ohhMZUwzEqJUqHL6TfNPug5ESrv+7EdbsluXB4i5A6s3bpl44k3ipLscmr2W2AzqDG1IdT 9jg= X-SBRS: 2.7 X-MesageID: 3787857 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3787857" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:36:02 +0100 Message-ID: <20190802153606.32061-32-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 31/35] libxl: Use ev_qmp for libxl_send_trigger 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" Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_domain.c | 49 ++++++++++++++++++++++++++++++------ tools/libxl/libxl_internal.h | 2 -- tools/libxl/libxl_qmp.c | 5 ---- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index cd71900350..08d3fc9fbc 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1556,19 +1556,39 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t d= omid, return AO_INPROGRESS; } =20 -static int libxl__domain_s3_resume(libxl__gc *gc, int domid) +static void domain_s3_resume_done(libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc); + +static void domain_s3_resume(libxl__ao *ao, libxl__egc *egc, int domid) { + AO_GC; + libxl__ev_qmp *qmp; int rc =3D 0; + int r; + + GCNEW(qmp); + libxl__ev_qmp_init(qmp); + qmp->ao =3D ao; + qmp->domid =3D domid; + qmp->payload_fd =3D -1; + qmp->callback =3D domain_s3_resume_done; =20 switch (libxl__domain_type(gc, domid)) { case LIBXL_DOMAIN_TYPE_HVM: switch (libxl__device_model_version_running(gc, domid)) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: - rc =3D xc_hvm_param_set(CTX->xch, domid, HVM_PARAM_ACPI_S_STAT= E, 0); + r =3D xc_hvm_param_set(CTX->xch, domid, HVM_PARAM_ACPI_S_STATE= , 0); + if (r) { + LOGED(ERROR, domid, "Send trigger '%s' failed", + libxl_trigger_to_string(LIBXL_TRIGGER_S3RESUME)); + rc =3D ERROR_FAIL; + } break; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - rc =3D libxl__qmp_system_wakeup(gc, domid); - break; + rc =3D libxl__ev_qmp_send(gc, qmp, "system_wakeup", NULL); + if (rc) goto out; + return; default: rc =3D ERROR_INVAL; break; @@ -1579,7 +1599,22 @@ static int libxl__domain_s3_resume(libxl__gc *gc, in= t domid) break; } =20 - return rc; +out: + domain_s3_resume_done(egc, qmp, NULL, rc); +} + +static void domain_s3_resume_done(libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + EGC_GC; + + if (rc) + LOGD(ERROR, qmp->domid, "Send trigger '%s' failed, rc=3D%d", + libxl_trigger_to_string(LIBXL_TRIGGER_S3RESUME), rc); + + libxl__ev_qmp_dispose(gc, qmp); + libxl__ao_complete(egc, qmp->ao, rc); } =20 int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid, @@ -1611,8 +1646,8 @@ int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid, XEN_DOMCTL_SENDTRIGGER_RESET, vcpuid); break; case LIBXL_TRIGGER_S3RESUME: - rc =3D libxl__domain_s3_resume(gc, domid); - break; + domain_s3_resume(ao, egc, domid); /* must be last */ + return AO_INPROGRESS; default: rc =3D -1; errno =3D EINVAL; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 3e7cb4005d..c6b9655af2 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1983,8 +1983,6 @@ typedef struct libxl__qmp_handler libxl__qmp_handler; */ _hidden libxl__qmp_handler *libxl__qmp_initialize(libxl__gc *gc, uint32_t domid); -/* Resume hvm domain */ -_hidden int libxl__qmp_system_wakeup(libxl__gc *gc, int domid); /* Resume QEMU. */ _hidden int libxl__qmp_resume(libxl__gc *gc, int domid); /* Load current QEMU state from file. */ diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 8fac737fad..40043a0a45 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -752,11 +752,6 @@ static int qmp_run_command(libxl__gc *gc, int domid, return rc; } =20 -int libxl__qmp_system_wakeup(libxl__gc *gc, int domid) -{ - return qmp_run_command(gc, domid, "system_wakeup", NULL, NULL, NULL); -} - int libxl__qmp_restore(libxl__gc *gc, int domid, const char *state_file) { libxl__json_object *args =3D NULL; --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761534; cv=none; d=zoho.com; s=zohoarc; b=ZcujTW5bD5sAPoY8w2Zv1uQVgNh8r6uwdsb3loDlZn38xJWvXHcAqHWAqYjw+uKGnBB3joMaIV0L6DSj/230i+w9+JUhQd28XqXbOPoqe7yC4dADemdcIMo7U7pvakfqr/kQi/R7FXukIncyqohBn0dK6CbMjVgvcpntm8Qo+Tw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761534; 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=5/vmSpvxDYCaAxNApLckWysVLLCP0rNANotwTbPp2DA=; b=dAmiM/zDi39gA8TikYjp78E3wTq+NLFb2nWTgWfohYyT+ZWmvjvQuDBIJ8TTAgZ2x14GhRNJBHRyms1E+gnsSwQbVaOYLeY260ORMReJe6CzqFCljDItqAYaO7epQfvRpY0Lw4Pix+HOt1Koat5ziOL4ghY70V4s6znBXR54K64= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761534673837.1823081959471; Fri, 2 Aug 2019 08:58:54 -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 1htZwj-0006Dg-MN; Fri, 02 Aug 2019 15:58:21 +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 1htZwg-00067y-MM for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:18 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 56d67ab0-b53e-11e9-a82f-d74d7edca8ec; Fri, 02 Aug 2019 15:58:16 +0000 (UTC) X-Inumbo-ID: 56d67ab0-b53e-11e9-a82f-d74d7edca8ec Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: pbKiToo7/G4gAxD0gP+aXCl+MK+IX1CGSK/RyALmc+QmVjRvxCRVrnuL9hivfiWvcDF6kqvrVZ FRLHzXTmBDzPYbQtYZDiGNC30bXicw6NXwlgznegJ9G1ujlZgxZ9uhK8ZB4uz5Z0Z8Dl4rzbVY z9EQW+hswiJkCv1/+hQafrsDGYZsXD3P+2xtcdlFYpW3eMALtMu62CzYJcY0snYb83aBdTSeMv E9c5Wd9QTsDNyESpYHyfrqFqt9/vvCeGAVeWq1okAjoRNMuvBWIK8mvkxtsS9NA585XYUyI3+/ mW8= X-SBRS: 2.7 X-MesageID: 3787823 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3787823" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:36:03 +0100 Message-ID: <20190802153606.32061-33-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 32/35] libxl: Use ev_qmp in libxl_set_vcpuonline 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" Removed libxl__qmp_cpu_add since it's not used anymore. `cpumap' arg of libxl__set_vcpuonline_xenstore is constified. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_domain.c | 205 ++++++++++++++++++++++++++--------- tools/libxl/libxl_internal.h | 2 - tools/libxl/libxl_qmp.c | 9 -- 3 files changed, 153 insertions(+), 63 deletions(-) diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 08d3fc9fbc..4726e27d20 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1432,8 +1432,8 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint3= 2_t domid, } =20 static int libxl__set_vcpuonline_xenstore(libxl__gc *gc, uint32_t domid, - libxl_bitmap *cpumap, - const libxl_dominfo *info) + const libxl_bitmap *cpumap, + const libxl_dominfo *info) { char *dompath; xs_transaction_t t; @@ -1457,43 +1457,27 @@ static int libxl__set_vcpuonline_xenstore(libxl__gc= *gc, uint32_t domid, return rc; } =20 -static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid, - libxl_bitmap *cpumap, - const libxl_dominfo *info) -{ - int i, rc; - libxl_bitmap current_map, final_map; - - libxl_bitmap_init(¤t_map); - libxl_bitmap_init(&final_map); - - libxl_bitmap_alloc(CTX, ¤t_map, info->vcpu_max_id + 1); - libxl_bitmap_set_none(¤t_map); - rc =3D libxl__qmp_query_cpus(gc, domid, ¤t_map); - if (rc) { - LOGD(ERROR, domid, "Failed to query cpus"); - goto out; - } - - libxl_bitmap_copy_alloc(CTX, &final_map, cpumap); - - libxl_for_each_set_bit(i, current_map) - libxl_bitmap_reset(&final_map, i); - - libxl_for_each_set_bit(i, final_map) { - rc =3D libxl__qmp_cpu_add(gc, domid, i); - if (rc) { - LOGD(ERROR, domid, "Failed to add cpu %d", i); - goto out; - } - } - - rc =3D 0; -out: - libxl_bitmap_dispose(¤t_map); - libxl_bitmap_dispose(&final_map); - return rc; -} +typedef struct set_vcpuonline_state { + libxl__ev_qmp qmp; + libxl__ev_time timeout; + const libxl_bitmap *cpumap; + libxl_dominfo info; + libxl_bitmap final_map; + int index; /* for loop on final_map */ +} set_vcpuonline_state; + +static void set_vcpuonline_qmp_cpus_queried(libxl__egc *, libxl__ev_qmp *, + const libxl__json_object *, + int rc); +static void set_vcpuonline_qmp_add_cpu(libxl__egc *, libxl__ev_qmp *, + const libxl__json_object *response, + int rc); +static void set_vcpuonline_timeout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc); +static void set_vcpuonline_done(libxl__egc *egc, + set_vcpuonline_state *svos, + int rc); =20 int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpumap, @@ -1501,11 +1485,22 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t d= omid, { AO_CREATE(ctx, domid, ao_how); int rc, maxcpus; - libxl_dominfo info; + set_vcpuonline_state *svos; =20 - libxl_dominfo_init(&info); + GCNEW(svos); + libxl__ev_qmp_init(&svos->qmp); + svos->qmp.ao =3D ao; + svos->qmp.domid =3D domid; + svos->qmp.payload_fd =3D -1; + libxl__ev_time_init(&svos->timeout); + libxl_dominfo_init(&svos->info); + libxl_bitmap_init(&svos->final_map); =20 - rc =3D libxl_domain_info(CTX, &info, domid); + /* Convenience aliases */ + libxl_dominfo *info =3D &svos->info; + libxl__ev_qmp *qmp =3D &svos->qmp; + + rc =3D libxl_domain_info(CTX, info, domid); if (rc < 0) { LOGED(ERROR, domid, "Getting domain info list"); goto out; @@ -1518,10 +1513,10 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t d= omid, rc =3D ERROR_FAIL; goto out; } - if (maxcpus > info.vcpu_max_id + 1) + if (maxcpus > info->vcpu_max_id + 1) { LOGED(ERROR, domid, "Requested %d VCPUs, however maxcpus is %d!", - maxcpus, info.vcpu_max_id + 1); + maxcpus, info->vcpu_max_id + 1); rc =3D ERROR_FAIL; goto out; } @@ -1532,8 +1527,14 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t do= mid, case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: break; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - rc =3D libxl__set_vcpuonline_qmp(gc, domid, cpumap, &info); - break; + rc =3D libxl__ev_time_register_rel(ao, &svos->timeout, + set_vcpuonline_timeout, + LIBXL_QMP_CMD_TIMEOUT * 1000); + if (rc) goto out; + qmp->callback =3D set_vcpuonline_qmp_cpus_queried; + rc =3D libxl__ev_qmp_send(gc, qmp, "query-cpus", NULL); + if (rc) goto out; + return AO_INPROGRESS; default: rc =3D ERROR_INVAL; } @@ -1545,15 +1546,115 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t = domid, rc =3D ERROR_INVAL; } =20 - if (!rc) - rc =3D libxl__set_vcpuonline_xenstore(gc, domid, cpumap, &info); +out: + set_vcpuonline_done(egc, svos, rc); /* must be last */ + return AO_INPROGRESS; +} + +static void set_vcpuonline_qmp_cpus_queried(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc) +{ + EGC_GC; + set_vcpuonline_state *svos =3D CONTAINER_OF(qmp, *svos, qmp); + const libxl__json_object *cpu; + int i; + libxl_bitmap current_map; + + /* Convenience aliases */ + libxl_bitmap *final_map =3D &svos->final_map; + + libxl_bitmap_init(¤t_map); + + if (rc) goto out; + + libxl_bitmap_alloc(CTX, ¤t_map, svos->info.vcpu_max_id + 1); + libxl_bitmap_set_none(¤t_map); + + for (i =3D 0; (cpu =3D libxl__json_array_get(response, i)); i++) { + unsigned int cpu_index; + const libxl__json_object *o; + + o =3D libxl__json_map_get("CPU", cpu, JSON_INTEGER); + if (!o) { + LOGD(ERROR, qmp->domid, "Failed to retrieve CPU index."); + rc =3D ERROR_QEMU_API; + goto out; + } + + cpu_index =3D libxl__json_object_get_integer(o); + libxl_bitmap_set(¤t_map, cpu_index); + } + + + libxl_bitmap_copy_alloc(CTX, final_map, svos->cpumap); + + libxl_for_each_set_bit(i, current_map) { + libxl_bitmap_reset(final_map, i); + } =20 out: - libxl_dominfo_dispose(&info); - if (rc) - return AO_CREATE_FAIL(rc); + libxl_bitmap_dispose(¤t_map); + svos->index =3D -1; + set_vcpuonline_qmp_add_cpu(egc, qmp, NULL, rc); /* must be last */ +} + +static void set_vcpuonline_qmp_add_cpu(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc) +{ + STATE_AO_GC(qmp->ao); + set_vcpuonline_state *svos =3D CONTAINER_OF(qmp, *svos, qmp); + libxl__json_object *args =3D NULL; + + /* Convenience aliases */ + libxl_bitmap *map =3D &svos->final_map; + + if (rc) goto out; + + while (libxl_bitmap_cpu_valid(map, ++svos->index)) { + if (libxl_bitmap_test(map, svos->index)) { + qmp->callback =3D set_vcpuonline_qmp_add_cpu; + libxl__qmp_param_add_integer(gc, &args, "id", svos->index); + rc =3D libxl__ev_qmp_send(gc, qmp, "cpu-add", args); + if (rc) goto out; + return; + } + } + +out: + set_vcpuonline_done(egc, svos, rc); +} + +static void set_vcpuonline_timeout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc) +{ + EGC_GC; + set_vcpuonline_state *svos =3D CONTAINER_OF(ev, *svos, timeout); + + if (rc =3D=3D ERROR_TIMEDOUT) + LOGD(ERROR, svos->qmp.domid, + "Setting CPU online in QEMU timed out"); + + set_vcpuonline_done(egc, svos, rc); +} + +static void set_vcpuonline_done(libxl__egc *egc, + set_vcpuonline_state *svos, + int rc) +{ + STATE_AO_GC(svos->qmp.ao); + + /* Convenience aliases */ + libxl_domid domid =3D svos->qmp.domid; + + if (!rc) + rc =3D libxl__set_vcpuonline_xenstore(gc, domid, svos->cpumap, + &svos->info); + + libxl_bitmap_dispose(&svos->final_map); + libxl_dominfo_dispose(&svos->info); + libxl__ev_qmp_dispose(gc, &svos->qmp); libxl__ao_complete(egc, ao, rc); - return AO_INPROGRESS; } =20 static void domain_s3_resume_done(libxl__egc *egc, libxl__ev_qmp *qmp, diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index c6b9655af2..03e99b23f5 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1987,8 +1987,6 @@ _hidden libxl__qmp_handler *libxl__qmp_initialize(lib= xl__gc *gc, _hidden int libxl__qmp_resume(libxl__gc *gc, int domid); /* Load current QEMU state from file. */ _hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filen= ame); -/* Add a virtual CPU */ -_hidden int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int index); /* Query the bitmap of CPUs */ _hidden int libxl__qmp_query_cpus(libxl__gc *gc, int domid, libxl_bitmap *map); diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 40043a0a45..27183bc6c4 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -767,15 +767,6 @@ int libxl__qmp_resume(libxl__gc *gc, int domid) return qmp_run_command(gc, domid, "cont", NULL, NULL, NULL); } =20 -int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int idx) -{ - libxl__json_object *args =3D NULL; - - libxl__qmp_param_add_integer(gc, &args, "id", idx); - - return qmp_run_command(gc, domid, "cpu-add", args, NULL, NULL); -} - static int query_cpus_callback(libxl__qmp_handler *qmp, const libxl__json_object *response, void *opaque) --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761537; cv=none; d=zoho.com; s=zohoarc; b=byk2oLJzADJIae+Dm5BfSrGB20VzCXHp36bwoe8Asczng5ti3RvSTknJy6LcgHo9z1LOgYQxT0PQlTMqhiOf6daX3JBm4WFGrPwedn3H3bH0WJyK8Y+5M23UdBnU4O0HiQ/qpklWa5M+rt6ejxd9ef4KfhBYZrK/Gr2C6xlzGzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761537; 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=2MoxYkDt1S+1VN/Wrps5Ei8FLxxggCnW9z0DgedIyJs=; b=Ei5XhODsfaPRUHXIouBAtdTRknXrAqr/UnvB5JzmcedjjMHoGzbKikdmZ18W33L0xOTo3rOutLKvGuB3loGDIw+odaW0PMC6eEeJ5kIfJ8rP0WHrkBD5tVdHOr+YkUFny3khHLDSBq7OHnHi862McbScSE0XbWRvO8k2P3BtkzA= ARC-Authentication-Results: i=1; mx.zoho.com; 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 156476153797813.919800609300864; Fri, 2 Aug 2019 08:58:57 -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 1htZws-0006Sk-07; Fri, 02 Aug 2019 15:58:30 +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 1htZwq-0006Q9-ES for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:28 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5c8cfe20-b53e-11e9-a756-af28f40f8b76; Fri, 02 Aug 2019 15:58:26 +0000 (UTC) X-Inumbo-ID: 5c8cfe20-b53e-11e9-a756-af28f40f8b76 Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 8tUW1R3M9FgMZ6W4R2LZpeBUCi7J9hhshiYdfJ9RdfgtfA11CmY1I+MLIX1re6H3ckaWntISkG J019ObP6MGqSlvBpnnb+qRIL/5qcR46dDJyLFqZLiTZmOH1JIfeyUpD0enS2llwNGj+dI/iUBe P+oEj86IjkV+fN5MsnV60ykcfBkNpyHUF+jU8csJ57/dc+JzlpmVrI+0J91LzTLXEbdJ1Q8Rfl lIdBSNOT2t1Bu5PWx9WYtF2Uxi73FlTO/sgwSRnWrOcFI14IJYszHFMQCbfIUp0KSuDN3qewQh Fmw= X-SBRS: 2.7 X-MesageID: 3911387 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3911387" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:36:04 +0100 Message-ID: <20190802153606.32061-34-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 33/35] libxl: Extract qmp_parse_query_cpus 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" The QMP command "query-cpus" is called from different places, extract the algorithm that parse the answer into a separate function. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_domain.c | 69 ++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 4726e27d20..b97e874a9c 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1457,6 +1457,35 @@ static int libxl__set_vcpuonline_xenstore(libxl__gc = *gc, uint32_t domid, return rc; } =20 +static int qmp_parse_query_cpus(libxl__gc *gc, + libxl_domid domid, + const libxl__json_object *response, + libxl_bitmap *const map) +{ + int i; + const libxl__json_object *cpu; + + libxl_bitmap_set_none(map); + /* Parse response to QMP command "query-cpus": + * [ { 'CPU': 'int',...} ] + */ + for (i =3D 0; (cpu =3D libxl__json_array_get(response, i)); i++) { + unsigned int cpu_index; + const libxl__json_object *o; + + o =3D libxl__json_map_get("CPU", cpu, JSON_INTEGER); + if (!o) { + LOGD(ERROR, domid, "Failed to retrieve CPU index."); + return ERROR_QEMU_API; + } + + cpu_index =3D libxl__json_object_get_integer(o); + libxl_bitmap_set(map, cpu_index); + } + + return 0; +} + typedef struct set_vcpuonline_state { libxl__ev_qmp qmp; libxl__ev_time timeout; @@ -1466,18 +1495,14 @@ typedef struct set_vcpuonline_state { int index; /* for loop on final_map */ } set_vcpuonline_state; =20 -static void set_vcpuonline_qmp_cpus_queried(libxl__egc *, libxl__ev_qmp *, - const libxl__json_object *, - int rc); -static void set_vcpuonline_qmp_add_cpu(libxl__egc *, libxl__ev_qmp *, - const libxl__json_object *response, - int rc); -static void set_vcpuonline_timeout(libxl__egc *egc, libxl__ev_time *ev, - const struct timeval *requested_abs, - int rc); +static void set_vcpuonline_qmp_cpus_queried(libxl__egc *, + libxl__ev_qmp *, const libxl__json_object *, int rc); +static void set_vcpuonline_qmp_add_cpu(libxl__egc *, + libxl__ev_qmp *, const libxl__json_object *response, int rc); +static void set_vcpuonline_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc); static void set_vcpuonline_done(libxl__egc *egc, - set_vcpuonline_state *svos, - int rc); + set_vcpuonline_state *svos, int rc); =20 int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpumap, @@ -1493,6 +1518,7 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t dom= id, svos->qmp.domid =3D domid; svos->qmp.payload_fd =3D -1; libxl__ev_time_init(&svos->timeout); + svos->cpumap =3D cpumap; libxl_dominfo_init(&svos->info); libxl_bitmap_init(&svos->final_map); =20 @@ -1556,7 +1582,6 @@ static void set_vcpuonline_qmp_cpus_queried(libxl__eg= c *egc, { EGC_GC; set_vcpuonline_state *svos =3D CONTAINER_OF(qmp, *svos, qmp); - const libxl__json_object *cpu; int i; libxl_bitmap current_map; =20 @@ -1568,23 +1593,8 @@ static void set_vcpuonline_qmp_cpus_queried(libxl__e= gc *egc, if (rc) goto out; =20 libxl_bitmap_alloc(CTX, ¤t_map, svos->info.vcpu_max_id + 1); - libxl_bitmap_set_none(¤t_map); - - for (i =3D 0; (cpu =3D libxl__json_array_get(response, i)); i++) { - unsigned int cpu_index; - const libxl__json_object *o; - - o =3D libxl__json_map_get("CPU", cpu, JSON_INTEGER); - if (!o) { - LOGD(ERROR, qmp->domid, "Failed to retrieve CPU index."); - rc =3D ERROR_QEMU_API; - goto out; - } - - cpu_index =3D libxl__json_object_get_integer(o); - libxl_bitmap_set(¤t_map, cpu_index); - } - + rc =3D qmp_parse_query_cpus(gc, qmp->domid, response, ¤t_map); + if (rc) goto out; =20 libxl_bitmap_copy_alloc(CTX, final_map, svos->cpumap); =20 @@ -1653,6 +1663,7 @@ static void set_vcpuonline_done(libxl__egc *egc, =20 libxl_bitmap_dispose(&svos->final_map); libxl_dominfo_dispose(&svos->info); + libxl__ev_time_deregister(gc, &svos->timeout); libxl__ev_qmp_dispose(gc, &svos->qmp); libxl__ao_complete(egc, ao, rc); } --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761528; cv=none; d=zoho.com; s=zohoarc; b=kJHtYJhkhitUV3xTbAU9Ryk95udNVEFBlTTQjv7ogM7WprygcjY6sQhCOPAetckdR4LnBRY1UM66n8ELfaptSCPvOF42ez6zJ7Gjtx3WHgDwzEVhqE08mcDLpaP6Wph0sB0EplcvR8cGTr8zzU04aLsVN1EBHoGPMtDnV8sXT2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761528; 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=LOScpKQhAgM2i8qEqJdAHZyFwrYZL+9sQtib8YnK2o0=; b=V2eXXWCzoTdwfFgNvLBrJp7YMt9MoCX2+ZgDlW+6pVl/Ppl/gnmt6fsOSNWnJGTPCw4ov4kgCFoGzfawQ/gZhKDfTK6/tKqPaigQhfuIIM8lBH4ZZBccPH3TfZkWrwswYpS2MGWCQni7fVnre5TDSdVD+LCdlzw/YkL5SSRZ+pg= ARC-Authentication-Results: i=1; mx.zoho.com; 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 156476152854811.95856387736751; Fri, 2 Aug 2019 08:58:48 -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 1htZw8-0005lY-MX; Fri, 02 Aug 2019 15:57:44 +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 1htZw7-0005lT-Mk for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:57:43 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 41901864-b53e-11e9-a0ec-5f7986644955; Fri, 02 Aug 2019 15:57:40 +0000 (UTC) X-Inumbo-ID: 41901864-b53e-11e9-a0ec-5f7986644955 Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: y3W7NMF+KWLERxRDL3PmPmo5OWlijjhHKY1LRJxtxtKonnU1JVAu3HdHrbj36KlCY5e7sDHUY+ mFAjN0z/JdI5f5oqjz7moFvqZ+L1yaqxnJa+KBGVjV+5IB8Vgk8az5kZE+EMUrhftOGm8WoToP dVlT8x+N40IHOFATNWXLNaS3+hSdKjVJ1VAYsWh1taRnfTGV7Y72t0FcoxlTupSjgStZ+HLnfq Pww/5BT7r4vFkVmrgEYMo7ThboPU5FGwWVUdYCeL4+tmQtG5FjMkCsBD1dJR7gqcoD83W0tEg2 mv0= X-SBRS: 2.7 X-MesageID: 3911343 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3911343" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:36:05 +0100 Message-ID: <20190802153606.32061-35-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 34/35] libxl: libxl_retrieve_domain_configuration now uses ev_qmp 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" This was the last user of libxl__qmp_query_cpus which can now be removed. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_domain.c | 163 ++++++++++++++++++++++++++++------- tools/libxl/libxl_internal.h | 3 - tools/libxl/libxl_qmp.c | 38 -------- 3 files changed, 131 insertions(+), 73 deletions(-) diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index b97e874a9c..6a8ffe10f0 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1800,27 +1800,6 @@ uint32_t libxl_vm_get_start_time(libxl_ctx *ctx, uin= t32_t domid) return ret; } =20 -/* For QEMU upstream we always need to provide the number of cpus present = to - * QEMU whether they are online or not; otherwise QEMU won't accept the sa= ved - * state. See implementation of libxl__qmp_query_cpus. - */ -static int libxl__update_avail_vcpus_qmp(libxl__gc *gc, uint32_t domid, - unsigned int max_vcpus, - libxl_bitmap *map) -{ - int rc; - - rc =3D libxl__qmp_query_cpus(gc, domid, map); - if (rc) { - LOGD(ERROR, domid, "Fail to get number of cpus"); - goto out; - } - - rc =3D 0; -out: - return rc; -} - static int libxl__update_avail_vcpus_xenstore(libxl__gc *gc, uint32_t domi= d, unsigned int max_vcpus, libxl_bitmap *map) @@ -1849,13 +1828,61 @@ static int libxl__update_avail_vcpus_xenstore(libxl= __gc *gc, uint32_t domid, return rc; } =20 +typedef struct { + libxl__ev_qmp qmp; + libxl__ev_time timeout; + libxl_domain_config *d_config; /* user pointer */ + libxl__ev_lock ev_lock; + libxl_bitmap qemuu_cpus; +} retrieve_domain_configuration_state; + +static void retrieve_domain_configuration_lock_acquired( + libxl__egc *egc, libxl__ev_lock *, int rc); +static void retrieve_domain_configuration_cpu_queried( + libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, int rc); +static void retrieve_domain_configuration_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc); +static void retrieve_domain_configuration_end(libxl__egc *egc, + retrieve_domain_configuration_state *rdcs, int rc); + int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, libxl_domain_config *d_config, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); - int rc; + retrieve_domain_configuration_state *rdcs; + + GCNEW(rdcs); + libxl__ev_qmp_init(&rdcs->qmp); + rdcs->qmp.ao =3D ao; + rdcs->qmp.domid =3D domid; + rdcs->qmp.payload_fd =3D -1; + libxl__ev_time_init(&rdcs->timeout); + rdcs->d_config =3D d_config; + libxl_bitmap_init(&rdcs->qemuu_cpus); + libxl__ev_lock_init(&rdcs->ev_lock); + rdcs->ev_lock.ao =3D ao; + rdcs->ev_lock.domid =3D domid; + rdcs->ev_lock.callback =3D retrieve_domain_configuration_lock_acquired; + libxl__ev_lock_get(egc, &rdcs->ev_lock); + return AO_INPROGRESS; +} + +static void retrieve_domain_configuration_lock_acquired( + libxl__egc *egc, libxl__ev_lock *ev_lock, int rc) +{ + retrieve_domain_configuration_state *rdcs =3D + CONTAINER_OF(ev_lock, *rdcs, ev_lock); + STATE_AO_GC(rdcs->qmp.ao); libxl__domain_userdata_lock *lock =3D NULL; + bool has_callback =3D false; + + /* Convenience aliases */ + libxl_domid domid =3D rdcs->qmp.domid; + libxl_domain_config *const d_config =3D rdcs->d_config; + + if (rc) goto out; =20 lock =3D libxl__lock_domain_userdata(gc, domid); if (!lock) { @@ -1870,10 +1897,81 @@ int libxl_retrieve_domain_configuration(libxl_ctx *= ctx, uint32_t domid, goto out; } =20 + libxl__unlock_domain_userdata(lock); + lock =3D NULL; + + /* We start by querying QEMU, if it is running, for its cpumap as this + * is a long operation. */ + if (d_config->b_info.type =3D=3D LIBXL_DOMAIN_TYPE_HVM && + libxl__device_model_version_running(gc, domid) =3D=3D + LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { + /* For QEMU upstream we always need to provide the number + * of cpus present to QEMU whether they are online or not; + * otherwise QEMU won't accept the saved state. + */ + rc =3D libxl__ev_time_register_rel(ao, &rdcs->timeout, + retrieve_domain_configuration_timeout, + LIBXL_QMP_CMD_TIMEOUT * 1000); + if (rc) goto out; + libxl_bitmap_alloc(CTX, &rdcs->qemuu_cpus, + d_config->b_info.max_vcpus); + rdcs->qmp.callback =3D retrieve_domain_configuration_cpu_queried; + rc =3D libxl__ev_qmp_send(gc, &rdcs->qmp, "query-cpus", NULL); + if (rc) goto out; + has_callback =3D true; + } + +out: + if (lock) libxl__unlock_domain_userdata(lock); + if (!has_callback) + retrieve_domain_configuration_end(egc, rdcs, rc); +} + +static void retrieve_domain_configuration_cpu_queried( + libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, int rc) +{ + EGC_GC; + retrieve_domain_configuration_state *rdcs =3D + CONTAINER_OF(qmp, *rdcs, qmp); + + if (rc) goto out; + + rc =3D qmp_parse_query_cpus(gc, qmp->domid, response, &rdcs->qemuu_cpu= s); + +out: + retrieve_domain_configuration_end(egc, rdcs, rc); +} + +static void retrieve_domain_configuration_timeout(libxl__egc *egc, + libxl__ev_time *ev, const struct timeval *requested_abs, int rc) +{ + retrieve_domain_configuration_state *rdcs =3D + CONTAINER_OF(ev, *rdcs, timeout); + + retrieve_domain_configuration_end(egc, rdcs, rc); +} + +static void retrieve_domain_configuration_end(libxl__egc *egc, + retrieve_domain_configuration_state *rdcs, int rc) +{ + STATE_AO_GC(rdcs->qmp.ao); + libxl__domain_userdata_lock *lock; + + /* Convenience aliases */ + libxl_domain_config *const d_config =3D rdcs->d_config; + libxl_domid domid =3D rdcs->qmp.domid; + + lock =3D libxl__lock_domain_userdata(gc, domid); + if (!lock) { + rc =3D ERROR_LOCK_FAIL; + goto out; + } + /* Domain name */ { char *domname; - domname =3D libxl_domid_to_name(ctx, domid); + domname =3D libxl_domid_to_name(CTX, domid); if (!domname) { LOGD(ERROR, domid, "Fail to get domain name"); goto out; @@ -1886,13 +1984,13 @@ int libxl_retrieve_domain_configuration(libxl_ctx *= ctx, uint32_t domid, { libxl_dominfo info; libxl_dominfo_init(&info); - rc =3D libxl_domain_info(ctx, &info, domid); + rc =3D libxl_domain_info(CTX, &info, domid); if (rc) { LOGD(ERROR, domid, "Fail to get domain info"); libxl_dominfo_dispose(&info); goto out; } - libxl_uuid_copy(ctx, &d_config->c_info.uuid, &info.uuid); + libxl_uuid_copy(CTX, &d_config->c_info.uuid, &info.uuid); libxl_dominfo_dispose(&info); } =20 @@ -1913,8 +2011,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ct= x, uint32_t domid, assert(version !=3D LIBXL_DEVICE_MODEL_VERSION_UNKNOWN); switch (version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - rc =3D libxl__update_avail_vcpus_qmp(gc, domid, - max_vcpus, map); + libxl_bitmap_copy(CTX, map, &rdcs->qemuu_cpus); break; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: rc =3D libxl__update_avail_vcpus_xenstore(gc, domid, @@ -1939,6 +2036,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ct= x, uint32_t domid, } } =20 + /* Memory limits: * * Currently there are three memory limits: @@ -1972,7 +2070,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ct= x, uint32_t domid, /* Scheduler params */ { libxl_domain_sched_params_dispose(&d_config->b_info.sched_params); - rc =3D libxl_domain_sched_params_get(ctx, domid, + rc =3D libxl_domain_sched_params_get(CTX, domid, &d_config->b_info.sched_params); if (rc) { LOGD(ERROR, domid, "Fail to get scheduler parameters"); @@ -2034,7 +2132,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ct= x, uint32_t domid, =20 if (j < num) { /* found in xenstore */ if (dt->merge) - dt->merge(ctx, p + dt->dev_elem_size * j, q); + dt->merge(CTX, p + dt->dev_elem_size * j, q); } else { /* not found in xenstore */ LOGD(WARN, domid, "Device present in JSON but not in xenstore, igno= red"); @@ -2062,11 +2160,12 @@ int libxl_retrieve_domain_configuration(libxl_ctx *= ctx, uint32_t domid, } =20 out: + libxl__ev_unlock(gc, &rdcs->ev_lock); if (lock) libxl__unlock_domain_userdata(lock); - if (rc) - return AO_CREATE_FAIL(rc); + libxl_bitmap_dispose(&rdcs->qemuu_cpus); + libxl__ev_qmp_dispose(gc, &rdcs->qmp); + libxl__ev_time_deregister(gc, &rdcs->timeout); libxl__ao_complete(egc, ao, rc); - return AO_INPROGRESS; } =20 /* diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 03e99b23f5..9144bc202d 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1987,9 +1987,6 @@ _hidden libxl__qmp_handler *libxl__qmp_initialize(lib= xl__gc *gc, _hidden int libxl__qmp_resume(libxl__gc *gc, int domid); /* Load current QEMU state from file. */ _hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filen= ame); -/* Query the bitmap of CPUs */ -_hidden int libxl__qmp_query_cpus(libxl__gc *gc, int domid, - libxl_bitmap *map); /* Start NBD server */ _hidden int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid, const char *host, const char *port= ); diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 27183bc6c4..9639d491d9 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -767,44 +767,6 @@ int libxl__qmp_resume(libxl__gc *gc, int domid) return qmp_run_command(gc, domid, "cont", NULL, NULL, NULL); } =20 -static int query_cpus_callback(libxl__qmp_handler *qmp, - const libxl__json_object *response, - void *opaque) -{ - libxl_bitmap *map =3D opaque; - unsigned int i; - const libxl__json_object *cpu =3D NULL; - int rc; - GC_INIT(qmp->ctx); - - libxl_bitmap_set_none(map); - for (i =3D 0; (cpu =3D libxl__json_array_get(response, i)); i++) { - unsigned int idx; - const libxl__json_object *o; - - o =3D libxl__json_map_get("CPU", cpu, JSON_INTEGER); - if (!o) { - LOGD(ERROR, qmp->domid, "Failed to retrieve CPU index."); - rc =3D ERROR_FAIL; - goto out; - } - - idx =3D libxl__json_object_get_integer(o); - libxl_bitmap_set(map, idx); - } - - rc =3D 0; -out: - GC_FREE; - return rc; -} - -int libxl__qmp_query_cpus(libxl__gc *gc, int domid, libxl_bitmap *map) -{ - return qmp_run_command(gc, domid, "query-cpus", NULL, - query_cpus_callback, map); -} - int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid, const char *host, const char *port) { --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 12:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1564761536; cv=none; d=zoho.com; s=zohoarc; b=RE/G9/k/gWICj+/0UUbBGSQD+ECI24+cfPPn/YFF1gnDHM0dlLH6Zm17b2mKHNssCvXSO8dAOjYxeeYTwIGPJRsQEdB6DZ8TeNJyUkVuBn94FHSklJaNSzyS8YyGjcYu4CD9U88Z5Eiz1rSTy0O25akn77OVLsaqm6otP62/2ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761536; 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=JJjsEMuRBtv9I6VI2CgU2YTbSrS9vAtcjO0gufYPbPY=; b=nmOJsVFl0GVvuR6I77ClObutNpFHi7eTgMWy68Cem7D86sAmO+I97Hs07D2rkNO5SCJ1YqDLkNSt/6H3B4jQHdClixSWOF9TXbocHkpXpUraU3GC5o/ZKEnxAutXdSewY3hnF5b6LYAU2auB5ZTOs4Ip0PTGnRIGPi7VJbfEPeE= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1564761536444311.8757980510113; Fri, 2 Aug 2019 08:58:56 -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 1htZwL-0005ob-PK; Fri, 02 Aug 2019 15:57:57 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwK-0005np-7m for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:57:56 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 4a78d4cb-b53e-11e9-8980-bc764e045a96; Fri, 02 Aug 2019 15:57:55 +0000 (UTC) X-Inumbo-ID: 4a78d4cb-b53e-11e9-8980-bc764e045a96 Authentication-Results: esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: /6TKK2qH5S5YElF3zwnOvD2vnWV1w9jTvnBMmkqf6FdWRB3RbWyPhDQewOhv3aOm5aPBzYLn18 OUBiWVNZWGoEz2PNbcK5ghH4Asmumgr18kd561LBb2VC1n796qMdA59gtzFFn/Qb25fceMy4ma Uuli3t5sNVOpGn8Ew04nwY5CfzGDGBf/o+kiPHVns+5UsuYy7b+xth58/nerb9VNxBZ6ql5m2H BLbajjkuveB+cYsfe7qMizwR7gDkErvwzEAvFQZ4MQO2uVMl7co+hTJQ7SB+Ud/9H5OIAohWLi 41o= X-SBRS: 2.7 X-MesageID: 3931659 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3931659" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:36:06 +0100 Message-ID: <20190802153606.32061-36-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 35/35] libxl: libxl_qemu_monitor_command now uses ev_qmp 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" Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_qmp.c | 52 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 9639d491d9..9aabad74fa 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -892,19 +892,67 @@ int libxl__qmp_hmp(libxl__gc *gc, int domid, const ch= ar *command_line, hmp_callback, output); } =20 + +typedef struct { + libxl__ev_qmp qmp; + char **output; /* user pointer */ +} qemu_monitor_command_state; + +static void qemu_monitor_command_done(libxl__egc *, libxl__ev_qmp *, + const libxl__json_object *response, + int rc); + int libxl_qemu_monitor_command(libxl_ctx *ctx, uint32_t domid, const char *command_line, char **output, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); + qemu_monitor_command_state *qmcs; + libxl__json_object *args =3D NULL; int rc; =20 - rc =3D libxl__qmp_hmp(gc, domid, command_line, output); + if (!output) { + rc =3D ERROR_INVAL; + goto out; + } =20 - libxl__ao_complete(egc, ao, rc); + GCNEW(qmcs); + libxl__ev_qmp_init(&qmcs->qmp); + qmcs->qmp.ao =3D ao; + qmcs->qmp.domid =3D domid; + qmcs->qmp.payload_fd =3D -1; + qmcs->qmp.callback =3D qemu_monitor_command_done; + qmcs->output =3D output; + libxl__qmp_param_add_string(gc, &args, "command-line", command_line); + rc =3D libxl__ev_qmp_send(gc, &qmcs->qmp, "human-monitor-command", arg= s); +out: + if (rc) return AO_CREATE_FAIL(rc); return AO_INPROGRESS; } =20 +static void qemu_monitor_command_done(libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + STATE_AO_GC(qmp->ao); + qemu_monitor_command_state *qmcs =3D CONTAINER_OF(qmp, *qmcs, qmp); + + if (rc) goto out; + + if (!libxl__json_object_is_string(response)) { + rc =3D ERROR_QEMU_API; + LOGD(ERROR, qmp->domid, "Response has unexpected format"); + goto out; + } + + *(qmcs->output) =3D + libxl__strdup(NOGC, libxl__json_object_get_string(response)); + rc =3D 0; + +out: + libxl__ev_qmp_dispose(gc, qmp); + libxl__ao_complete(egc, ao, rc); +} =20 /* * Functions using libxl__ev_qmp --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel