From nobody Tue May 14 11:51:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1683648462; cv=none; d=zohomail.com; s=zohoarc; b=WZusa9lnMsaTXhRiOvxVcC/ZKimOECW6HFSof/xVID5zKvLUIPnPB/KU2/kbPjCEXvN0UGwBDrBOHBSfYatRpNRpa+d+NN/4UEBv3vOjrgS65GrWdz1hlniLyf8q/CmCXGETbha9CtLfvRhmGxbU2dpKuxEPxk2T3IngRZsNj1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683648462; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C8CTgH7ikeYK7Qw0f3MvFSgbUxreSSzk+kEZoLhVA/0=; b=ICWqcbmHRIJFZ18Hbuab5y2oOF7naZOP/CqJw/6k8ueoqWjO4fyOumf1pBmgnWXGyJ+5owrijI9Gbf3tyRlBlv7NI+IdGGXwJ/eY+x1b1dHt+SHirXYx08ahQzrcMFWDgFMYOvAafT70HSaNJV0qecWzUH/m99DuuH3eOvJAbUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1683648462812505.6623405028347; Tue, 9 May 2023 09:07:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.532309.828451 (Exim 4.92) (envelope-from ) id 1pwPs2-0000vn-9b; Tue, 09 May 2023 16:07:22 +0000 Received: by outflank-mailman (output) from mailman id 532309.828451; Tue, 09 May 2023 16:07:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pwPs2-0000ve-5Y; Tue, 09 May 2023 16:07:22 +0000 Received: by outflank-mailman (input) for mailman id 532309; Tue, 09 May 2023 16:07:20 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pwPs0-0000D0-4s for xen-devel@lists.xenproject.org; Tue, 09 May 2023 16:07:20 +0000 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [2a00:1450:4864:20::432]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 930cb8cd-ee83-11ed-b229-6b7b168915f2; Tue, 09 May 2023 18:07:19 +0200 (CEST) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3079d2afedbso1453816f8f.0 for ; Tue, 09 May 2023 09:07:19 -0700 (PDT) Received: from localhost.localdomain (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id z8-20020adfec88000000b003062675d4c9sm14721479wrn.39.2023.05.09.09.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 09:07:17 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 930cb8cd-ee83-11ed-b229-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1683648438; x=1686240438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C8CTgH7ikeYK7Qw0f3MvFSgbUxreSSzk+kEZoLhVA/0=; b=YWKb3TvdvmBUuHMF8qViOwDV5Q82/U3E2031GP9ctVTf9vzSwxwWo7FhUrRvgQBbKt 1230pUK3FY99+eanU9+cUJIK2hlJaXnwTq1F3oCtHCCx1N+sALsSsancXrDq4EoLxfdg 7jLDQNpLtHdTt0LaLUvowtcy27TrYb/qb+e9U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683648438; x=1686240438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C8CTgH7ikeYK7Qw0f3MvFSgbUxreSSzk+kEZoLhVA/0=; b=Ys55Ojvv9eUX1bcuTwJB8K80YXTmJ1fuSSnxFwEITdzG/LHnAamvAuegdCsFBpX8Y4 jftFhvj/MahsPS90S1NHhXhIPcgiYjjqzmhNNUYrGkQ9B/YPgGb7Ie6l1uNDteXFzRi2 IAQ6de3QaAvjQZlNF1sZpXBVchseFzw0O0w0L4pKzbaEGop9jQCUbov0FqtQH9WrdosD QwfvfWF406rYI5rVWkr/6L5QVikCk5RxLcdmThgpyNxW5unE3nFw2LgFfFzqlXif+yyd TGH/fKqDzyWYbaDbeQgytU01NMNqY0ff8W8m0sn9PSzDMT9r7Ul4uC6JHSXl51Mf1Yq+ imMg== X-Gm-Message-State: AC+VfDwkALi50+/lfxvajQgfZFXMEzc2oEZ7aJuXGcPqPM8Oit45rxPG jaFbeJJETBUZuPtjjytFofsO1jmcZ0p2TzhFj0w= X-Google-Smtp-Source: ACHHUZ4vV84Q38n434zY8oRxhpiCROidaPnpGJBdsfSWBMNR2E8d7BwZIzd4dtGNMuVYWRch7vHH1Q== X-Received: by 2002:adf:df0c:0:b0:307:5912:789 with SMTP id y12-20020adfdf0c000000b0030759120789mr9728753wrl.66.1683648438284; Tue, 09 May 2023 09:07:18 -0700 (PDT) From: Alejandro Vallejo To: Xen-devel Cc: Alejandro Vallejo , Andrew Cooper , Christian Lindig , Wei Liu , Anthony PERARD , Juergen Gross , Christian Lindig Subject: [PATCH v4 1/3] tools: Modify single-domid callers of xc_domain_getinfolist() Date: Tue, 9 May 2023 17:07:10 +0100 Message-Id: <20230509160712.11685-2-alejandro.vallejo@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509160712.11685-1-alejandro.vallejo@cloud.com> References: <20230509160712.11685-1-alejandro.vallejo@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1683648464103100001 Content-Type: text/plain; charset="utf-8" xc_domain_getinfolist() internally relies on a sysctl that performs a linear search for the domids. Many callers of xc_domain_getinfolist() who require information about a precise domid are much better off calling xc_domain_getinfo_single() instead, that will use the getdomaininfo domctl instead and ensure the returned domid matches the requested one. The domtctl will find the domid faster too, because that uses hashed lists. Signed-off-by: Alejandro Vallejo Reviewed-by: Andrew Cooper Acked-by: Christian Lindig Reviewed-by: Anthony PERARD --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Cc: Christian Lindig v4: libxl: * Preserve distinction between "domain-not-found" and other errors * Renamed new rc variable to r, as the coding style --- tools/libs/light/libxl_dom.c | 17 ++++++----------- tools/libs/light/libxl_dom_suspend.c | 7 +------ tools/libs/light/libxl_domain.c | 18 ++++++++---------- tools/libs/light/libxl_mem.c | 4 ++-- tools/libs/light/libxl_sched.c | 14 +++++--------- tools/ocaml/libs/xc/xenctrl_stubs.c | 6 ++---- tools/xenpaging/xenpaging.c | 10 +++++----- 7 files changed, 29 insertions(+), 47 deletions(-) diff --git a/tools/libs/light/libxl_dom.c b/tools/libs/light/libxl_dom.c index 25fb716084..94fef37401 100644 --- a/tools/libs/light/libxl_dom.c +++ b/tools/libs/light/libxl_dom.c @@ -32,9 +32,9 @@ libxl_domain_type libxl__domain_type(libxl__gc *gc, uint3= 2_t domid) xc_domaininfo_t info; int ret; =20 - ret =3D xc_domain_getinfolist(ctx->xch, domid, 1, &info); - if (ret !=3D 1 || info.domain !=3D domid) { - LOG(ERROR, "unable to get domain type for domid=3D%"PRIu32, domid); + ret =3D xc_domain_getinfo_single(ctx->xch, domid, &info); + if (ret < 0) { + LOGED(ERROR, domid, "unable to get dominfo"); return LIBXL_DOMAIN_TYPE_INVALID; } if (info.flags & XEN_DOMINF_hvm_guest) { @@ -70,15 +70,10 @@ int libxl__domain_cpupool(libxl__gc *gc, uint32_t domid) xc_domaininfo_t info; int ret; =20 - ret =3D xc_domain_getinfolist(CTX->xch, domid, 1, &info); - if (ret !=3D 1) + ret =3D xc_domain_getinfo_single(CTX->xch, domid, &info); + if (ret < 0) { - LOGE(ERROR, "getinfolist failed %d", ret); - return ERROR_FAIL; - } - if (info.domain !=3D domid) - { - LOGE(ERROR, "got info for dom%d, wanted dom%d\n", info.domain, dom= id); + LOGED(ERROR, domid, "get domaininfo failed"); return ERROR_FAIL; } return info.cpupool; diff --git a/tools/libs/light/libxl_dom_suspend.c b/tools/libs/light/libxl_= dom_suspend.c index 4fa22bb739..6091a5f3f6 100644 --- a/tools/libs/light/libxl_dom_suspend.c +++ b/tools/libs/light/libxl_dom_suspend.c @@ -332,13 +332,8 @@ static void suspend_common_wait_guest_check(libxl__egc= *egc, /* Convenience aliases */ const uint32_t domid =3D dsps->domid; =20 - ret =3D xc_domain_getinfolist(CTX->xch, domid, 1, &info); + ret =3D xc_domain_getinfo_single(CTX->xch, domid, &info); if (ret < 0) { - LOGED(ERROR, domid, "unable to check for status of guest"); - goto err; - } - - if (!(ret =3D=3D 1 && info.domain =3D=3D domid)) { LOGED(ERROR, domid, "guest we were suspending has been destroyed"); goto err; } diff --git a/tools/libs/light/libxl_domain.c b/tools/libs/light/libxl_domai= n.c index 7f0986c185..5ee1544d9c 100644 --- a/tools/libs/light/libxl_domain.c +++ b/tools/libs/light/libxl_domain.c @@ -349,15 +349,11 @@ int libxl_domain_info(libxl_ctx *ctx, libxl_dominfo *= info_r, int ret; GC_INIT(ctx); =20 - ret =3D xc_domain_getinfolist(ctx->xch, domid, 1, &xcinfo); - if (ret<0) { - LOGED(ERROR, domid, "Getting domain info list"); - GC_FREE; - return ERROR_FAIL; - } - if (ret=3D=3D0 || xcinfo.domain !=3D domid) { + ret =3D xc_domain_getinfo_single(ctx->xch, domid, &xcinfo); + if (ret < 0) { + LOGED(ERROR, domid, "Getting domain info"); GC_FREE; - return ERROR_DOMAIN_NOTFOUND; + return errno =3D=3D ESRCH ? ERROR_DOMAIN_NOTFOUND : ERROR_FAIL; } =20 if (info_r) @@ -1657,14 +1653,16 @@ int libxl__resolve_domid(libxl__gc *gc, const char = *name, uint32_t *domid) libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid, int *nr_vcpus_out, int *nr_cpus_out) { + int r; GC_INIT(ctx); libxl_vcpuinfo *ptr, *ret; xc_domaininfo_t domaininfo; xc_vcpuinfo_t vcpuinfo; unsigned int nr_vcpus; =20 - if (xc_domain_getinfolist(ctx->xch, domid, 1, &domaininfo) !=3D 1) { - LOGED(ERROR, domid, "Getting infolist"); + r =3D xc_domain_getinfo_single(ctx->xch, domid, &domaininfo); + if (r < 0) { + LOGED(ERROR, domid, "Getting dominfo"); GC_FREE; return NULL; } diff --git a/tools/libs/light/libxl_mem.c b/tools/libs/light/libxl_mem.c index 92ec09f4cf..44e554adba 100644 --- a/tools/libs/light/libxl_mem.c +++ b/tools/libs/light/libxl_mem.c @@ -323,8 +323,8 @@ retry_transaction: libxl__xs_printf(gc, t, GCSPRINTF("%s/memory/target", dompath), "%"PRIu64, new_target_memkb); =20 - r =3D xc_domain_getinfolist(ctx->xch, domid, 1, &info); - if (r !=3D 1 || info.domain !=3D domid) { + r =3D xc_domain_getinfo_single(ctx->xch, domid, &info); + if (r < 0) { abort_transaction =3D 1; rc =3D ERROR_FAIL; goto out; diff --git a/tools/libs/light/libxl_sched.c b/tools/libs/light/libxl_sched.c index 7c53dc60e6..841c05b0ef 100644 --- a/tools/libs/light/libxl_sched.c +++ b/tools/libs/light/libxl_sched.c @@ -219,13 +219,11 @@ static int sched_credit_domain_set(libxl__gc *gc, uin= t32_t domid, xc_domaininfo_t domaininfo; int rc; =20 - rc =3D xc_domain_getinfolist(CTX->xch, domid, 1, &domaininfo); + rc =3D xc_domain_getinfo_single(CTX->xch, domid, &domaininfo); if (rc < 0) { - LOGED(ERROR, domid, "Getting domain info list"); - return ERROR_FAIL; + LOGED(ERROR, domid, "Getting domain info"); + return errno =3D=3D ESRCH ? ERROR_INVAL : ERROR_FAIL; } - if (rc !=3D 1 || domaininfo.domain !=3D domid) - return ERROR_INVAL; =20 rc =3D xc_sched_credit_domain_get(CTX->xch, domid, &sdom); if (rc !=3D 0) { @@ -426,13 +424,11 @@ static int sched_credit2_domain_set(libxl__gc *gc, ui= nt32_t domid, xc_domaininfo_t info; int rc; =20 - rc =3D xc_domain_getinfolist(CTX->xch, domid, 1, &info); + rc =3D xc_domain_getinfo_single(CTX->xch, domid, &info); if (rc < 0) { LOGED(ERROR, domid, "Getting domain info"); - return ERROR_FAIL; + return errno =3D=3D ESRCH ? ERROR_INVAL : ERROR_FAIL; } - if (rc !=3D 1 || info.domain !=3D domid) - return ERROR_INVAL; =20 rc =3D xc_sched_credit2_domain_get(CTX->xch, domid, &sdom); if (rc !=3D 0) { diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenc= trl_stubs.c index 6ec9ed6d1e..f686db3124 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -497,10 +497,8 @@ CAMLprim value stub_xc_domain_getinfo(value xch_val, v= alue domid) xc_domaininfo_t info; int ret; =20 - ret =3D xc_domain_getinfolist(xch, Int_val(domid), 1, &info); - if (ret !=3D 1) - failwith_xc(xch); - if (info.domain !=3D Int_val(domid)) + ret =3D xc_domain_getinfo_single(xch, Int_val(domid), &info); + if (ret < 0) failwith_xc(xch); =20 result =3D alloc_domaininfo(&info); diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c index 6e5490315d..c7a9a82477 100644 --- a/tools/xenpaging/xenpaging.c +++ b/tools/xenpaging/xenpaging.c @@ -169,8 +169,8 @@ static int xenpaging_get_tot_pages(struct xenpaging *pa= ging) xc_domaininfo_t domain_info; int rc; =20 - rc =3D xc_domain_getinfolist(xch, paging->vm_event.domain_id, 1, &doma= in_info); - if ( rc !=3D 1 ) + rc =3D xc_domain_getinfo_single(xch, paging->vm_event.domain_id, &doma= in_info); + if ( rc < 0 ) { PERROR("Error getting domain info"); return -1; @@ -424,9 +424,9 @@ static struct xenpaging *xenpaging_init(int argc, char = *argv[]) /* Get max_pages from guest if not provided via cmdline */ if ( !paging->max_pages ) { - rc =3D xc_domain_getinfolist(xch, paging->vm_event.domain_id, 1, - &domain_info); - if ( rc !=3D 1 ) + rc =3D xc_domain_getinfo_single(xch, paging->vm_event.domain_id, + &domain_info); + if ( rc < 0 ) { PERROR("Error getting domain info"); goto err; --=20 2.34.1 From nobody Tue May 14 11:51:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1683648468; cv=none; d=zohomail.com; s=zohoarc; b=MHHvA3ZvHxz0E+mySuVWR5M1QWHm/sr0vTfXcRWJ7p7WAcH97+9Hb9/u5ehsRkoGt0VhtgRYa0b/XLgy8v3AFMzCnF5OUPYY0ux2qwVx5CApQj1ffUX5zf6JBmYoIT83eJLAQbvgEFyH6VPEiCmxx0t9lNdBk8Wm//PNgvLmKWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683648468; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FdWx27kUD3c/g7EnD0npPaYTUD8O2LdCMzKt1vZWnvs=; b=V2gUdKAMUXuhb0P1WvmRDCLYT6Finj7vawJTjg8l5zQzXSh+JWzJvaZVIewuALdf3ibCj6SmJOUxzKmxQWEFiSTrpspS1VboIIXiYMSad8vk/iiLHPZUjUoc8a4r1j1K9vq89it6XEqdd6wNHtg/i+SS/qw20wUKYF6EL6K4L/U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1683648468047605.9948220143045; Tue, 9 May 2023 09:07:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.532310.828461 (Exim 4.92) (envelope-from ) id 1pwPs4-0001Cw-Ho; Tue, 09 May 2023 16:07:24 +0000 Received: by outflank-mailman (output) from mailman id 532310.828461; Tue, 09 May 2023 16:07:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pwPs4-0001Cp-Dh; Tue, 09 May 2023 16:07:24 +0000 Received: by outflank-mailman (input) for mailman id 532310; Tue, 09 May 2023 16:07:23 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pwPs3-0000D0-9k for xen-devel@lists.xenproject.org; Tue, 09 May 2023 16:07:23 +0000 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [2a00:1450:4864:20::334]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 942bfa1c-ee83-11ed-b229-6b7b168915f2; Tue, 09 May 2023 18:07:21 +0200 (CEST) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f42c865534so7986465e9.2 for ; Tue, 09 May 2023 09:07:21 -0700 (PDT) Received: from localhost.localdomain (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id z8-20020adfec88000000b003062675d4c9sm14721479wrn.39.2023.05.09.09.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 09:07:18 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 942bfa1c-ee83-11ed-b229-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1683648440; x=1686240440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FdWx27kUD3c/g7EnD0npPaYTUD8O2LdCMzKt1vZWnvs=; b=KySMYdqEVQpQdQFmCmq5jpRPclpN6C82tDy22MG3CR/zw+++MKOINzj3NhEzxPIzeS 4eq1SSpdMnzzjfR7etWyHEXQv6Gc5IkhcWXpuXjb9URL+4XITQd1NQFCiqI6X2FjAias vMySbXkFKKhsazRpGPfxGcVO/tCag28r7XQgw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683648440; x=1686240440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FdWx27kUD3c/g7EnD0npPaYTUD8O2LdCMzKt1vZWnvs=; b=Mgy2e46pcBhV3tHde49XALpGkSSFJ5Jm90oYJ/zTycWToUsT0DwGKednvaZ49c/cDF 3EGmbIkVnxvU/O0CXDjjt39LcfGllu6eOOW5Xi6PDS4qGaaKpxFjfnukqpBwK08tQ9cc T4W9sJpLx9iUtg7UFqIOQmPRHLkQGDjw2Rns+DYhJn6cutd0QMXRyWLT1GK0T/eq1Sqo SK4BCxao1GAW2ZErOSAOBjYjQwmbq+Bwmo3WxnnD3+EI4KV9oXo++MjdtYBAI5zy7An4 196tom6Rv+cYdaw9DMaePNU24fRocUXc5TpZvL6PIbg3605u9pZyoIGpKZ9zQpuH/5Hx Ciew== X-Gm-Message-State: AC+VfDxC4gCnPYbtHiSqL0gX+WyB7zikaZprnGUqI8hbeW0oDz2gpmra 2AEb3nMihwJ0ohEOuq6JUBZ9cwXykBxTtOkSO0M= X-Google-Smtp-Source: ACHHUZ4+VlZnDWiF1GGVi4KD31HWPi7em92+f1lJPMyFKWcMxT6v2fAPb61P+syOAkQG17RYjhF2NQ== X-Received: by 2002:a1c:f406:0:b0:3f0:7e56:82a4 with SMTP id z6-20020a1cf406000000b003f07e5682a4mr10834428wma.18.1683648439985; Tue, 09 May 2023 09:07:19 -0700 (PDT) From: Alejandro Vallejo To: Xen-devel Cc: Alejandro Vallejo , Andrew Cooper , Wei Liu , Anthony PERARD , Tim Deegan , George Dunlap , Juergen Gross Subject: [PATCH v4 2/3] tools: Use new xc function for some xc_domain_getinfo() calls Date: Tue, 9 May 2023 17:07:11 +0100 Message-Id: <20230509160712.11685-3-alejandro.vallejo@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509160712.11685-1-alejandro.vallejo@cloud.com> References: <20230509160712.11685-1-alejandro.vallejo@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1683648470155100001 Content-Type: text/plain; charset="utf-8" Move calls that require a information about a single precisely identified domain to the new xc_domain_getinfo_single(). Signed-off-by: Alejandro Vallejo Reviewed-by: Andrew Cooper Acked-by: Anthony PERARD --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Tim Deegan Cc: George Dunlap Cc: Juergen Gross v4: Changed a line in libxl_x86_acpi.c to print errno/domid instead of rc --- tools/console/client/main.c | 7 ++--- tools/debugger/kdd/kdd-xen.c | 5 ++-- tools/libs/ctrl/xc_domain.c | 9 +++--- tools/libs/ctrl/xc_pagetab.c | 7 ++--- tools/libs/ctrl/xc_private.c | 9 +++--- tools/libs/ctrl/xc_private.h | 7 +++-- tools/libs/guest/xg_core.c | 23 ++++++-------- tools/libs/guest/xg_core.h | 6 ++-- tools/libs/guest/xg_core_arm.c | 10 +++---- tools/libs/guest/xg_core_x86.c | 18 +++++------ tools/libs/guest/xg_cpuid_x86.c | 40 +++++++++++++------------ tools/libs/guest/xg_dom_boot.c | 16 +++------- tools/libs/guest/xg_domain.c | 8 ++--- tools/libs/guest/xg_offline_page.c | 12 ++++---- tools/libs/guest/xg_private.h | 1 + tools/libs/guest/xg_resume.c | 20 ++++++------- tools/libs/guest/xg_sr_common.h | 2 +- tools/libs/guest/xg_sr_restore.c | 17 ++++------- tools/libs/guest/xg_sr_restore_x86_pv.c | 2 +- tools/libs/guest/xg_sr_save.c | 27 +++++++---------- tools/libs/guest/xg_sr_save_x86_pv.c | 6 ++-- tools/libs/light/libxl_sched.c | 16 +++++----- tools/libs/light/libxl_x86_acpi.c | 6 ++-- tools/misc/xen-hvmcrash.c | 6 ++-- tools/misc/xen-lowmemd.c | 6 ++-- tools/misc/xen-mfndump.c | 22 ++++++-------- tools/misc/xen-vmtrace.c | 6 ++-- tools/vchan/vchan-socket-proxy.c | 6 ++-- tools/xenstore/xenstored_domain.c | 15 +++++----- tools/xentrace/xenctx.c | 8 ++--- 30 files changed, 159 insertions(+), 184 deletions(-) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index 1a6fa162f7..6775006488 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -408,17 +408,16 @@ int main(int argc, char **argv) if (dom_path =3D=3D NULL) err(errno, "xs_get_domain_path()"); if (type =3D=3D CONSOLE_INVAL) { - xc_dominfo_t xcinfo; + xc_domaininfo_t xcinfo; xc_interface *xc_handle =3D xc_interface_open(0,0,0); if (xc_handle =3D=3D NULL) err(errno, "Could not open xc interface"); - if ( (xc_domain_getinfo(xc_handle, domid, 1, &xcinfo) !=3D 1) || - (xcinfo.domid !=3D domid) ) { + if (xc_domain_getinfo_single(xc_handle, domid, &xcinfo) < 0) { xc_interface_close(xc_handle); err(errno, "Failed to get domain information"); } /* default to pv console for pv guests and serial for hvm guests */ - if (xcinfo.hvm) + if (xcinfo.flags & XEN_DOMINF_hvm_guest) type =3D CONSOLE_SERIAL; else type =3D CONSOLE_PV; diff --git a/tools/debugger/kdd/kdd-xen.c b/tools/debugger/kdd/kdd-xen.c index e78c9311c4..e63e267023 100644 --- a/tools/debugger/kdd/kdd-xen.c +++ b/tools/debugger/kdd/kdd-xen.c @@ -570,7 +570,7 @@ kdd_guest *kdd_guest_init(char *arg, FILE *log, int ver= bosity) kdd_guest *g =3D NULL; xc_interface *xch =3D NULL; uint32_t domid; - xc_dominfo_t info; + xc_domaininfo_t info; =20 g =3D calloc(1, sizeof (kdd_guest)); if (!g)=20 @@ -590,7 +590,8 @@ kdd_guest *kdd_guest_init(char *arg, FILE *log, int ver= bosity) g->domid =3D domid; =20 /* Check that the domain exists and is HVM */ - if (xc_domain_getinfo(xch, domid, 1, &info) !=3D 1 || !info.hvm) + if (xc_domain_getinfo_single(xch, domid, &info) < 0 || + !(info.flags & XEN_DOMINF_hvm_guest)) goto err; =20 snprintf(g->id, (sizeof g->id) - 1,=20 diff --git a/tools/libs/ctrl/xc_domain.c b/tools/libs/ctrl/xc_domain.c index d5f0923088..66179e6f12 100644 --- a/tools/libs/ctrl/xc_domain.c +++ b/tools/libs/ctrl/xc_domain.c @@ -1960,15 +1960,14 @@ int xc_domain_memory_mapping( uint32_t add_mapping) { DECLARE_DOMCTL; - xc_dominfo_t info; + xc_domaininfo_t info; int ret =3D 0, rc; unsigned long done =3D 0, nr, max_batch_sz; =20 - if ( xc_domain_getinfo(xch, domid, 1, &info) !=3D 1 || - info.domid !=3D domid ) + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) { - PERROR("Could not get info for domain"); - return -EINVAL; + PERROR("Could not get info for dom%u", domid); + return -1; } if ( !xc_core_arch_auto_translated_physmap(&info) ) return 0; diff --git a/tools/libs/ctrl/xc_pagetab.c b/tools/libs/ctrl/xc_pagetab.c index db25c20247..d9f886633a 100644 --- a/tools/libs/ctrl/xc_pagetab.c +++ b/tools/libs/ctrl/xc_pagetab.c @@ -29,17 +29,16 @@ unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom, int vcpu, unsigned long long vi= rt) { - xc_dominfo_t dominfo; + xc_domaininfo_t dominfo; uint64_t paddr, mask, pte =3D 0; int size, level, pt_levels =3D 2; void *map; =20 - if (xc_domain_getinfo(xch, dom, 1, &dominfo) !=3D 1=20 - || dominfo.domid !=3D dom) + if (xc_domain_getinfo_single(xch, dom, &dominfo) < 0) return 0; =20 /* What kind of paging are we dealing with? */ - if (dominfo.hvm) { + if (dominfo.flags & XEN_DOMINF_hvm_guest) { struct hvm_hw_cpu ctx; if (xc_domain_hvm_getcontext_partial(xch, dom, HVM_SAVE_CODE(CPU), vcpu, diff --git a/tools/libs/ctrl/xc_private.c b/tools/libs/ctrl/xc_private.c index 2f99a7d2cf..6293a45531 100644 --- a/tools/libs/ctrl/xc_private.c +++ b/tools/libs/ctrl/xc_private.c @@ -441,11 +441,12 @@ int xc_machphys_mfn_list(xc_interface *xch, =20 long xc_get_tot_pages(xc_interface *xch, uint32_t domid) { - xc_dominfo_t info; - if ( (xc_domain_getinfo(xch, domid, 1, &info) !=3D 1) || - (info.domid !=3D domid) ) + xc_domaininfo_t info; + + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) return -1; - return info.nr_pages; + + return info.tot_pages; } =20 int xc_copy_to_domain_page(xc_interface *xch, diff --git a/tools/libs/ctrl/xc_private.h b/tools/libs/ctrl/xc_private.h index 80dc464c93..8faabaea67 100644 --- a/tools/libs/ctrl/xc_private.h +++ b/tools/libs/ctrl/xc_private.h @@ -16,6 +16,7 @@ #ifndef XC_PRIVATE_H #define XC_PRIVATE_H =20 +#include #include #include #include @@ -420,12 +421,12 @@ void *xc_vm_event_enable(xc_interface *xch, uint32_t = domain_id, int param, int do_dm_op(xc_interface *xch, uint32_t domid, unsigned int nr_bufs, ...); =20 #if defined (__i386__) || defined (__x86_64__) -static inline int xc_core_arch_auto_translated_physmap(const xc_dominfo_t = *info) +static inline int xc_core_arch_auto_translated_physmap(const xc_domaininfo= _t *info) { - return info->hvm; + return info->flags & XEN_DOMINF_hvm_guest; } #elif defined (__arm__) || defined(__aarch64__) -static inline int xc_core_arch_auto_translated_physmap(const xc_dominfo_t = *info) +static inline int xc_core_arch_auto_translated_physmap(const xc_domaininfo= _t *info) { return 1; } diff --git a/tools/libs/guest/xg_core.c b/tools/libs/guest/xg_core.c index c52f1161c1..f83436d6cb 100644 --- a/tools/libs/guest/xg_core.c +++ b/tools/libs/guest/xg_core.c @@ -349,7 +349,7 @@ elfnote_dump_none(xc_interface *xch, void *args, dumpco= re_rtn_t dump_rtn) static int elfnote_dump_core_header( xc_interface *xch, - void *args, dumpcore_rtn_t dump_rtn, const xc_dominfo_t *info, + void *args, dumpcore_rtn_t dump_rtn, const xc_domaininfo_t *info, int nr_vcpus, unsigned long nr_pages) { int sts; @@ -361,7 +361,8 @@ elfnote_dump_core_header( =20 elfnote.descsz =3D sizeof(header); elfnote.type =3D XEN_ELFNOTE_DUMPCORE_HEADER; - header.xch_magic =3D info->hvm ? XC_CORE_MAGIC_HVM : XC_CORE_MAGIC; + header.xch_magic =3D (info->flags & XEN_DOMINF_hvm_guest) ? XC_CORE_MA= GIC_HVM + : XC_CORE_MAGI= C; header.xch_nr_vcpus =3D nr_vcpus; header.xch_nr_pages =3D nr_pages; header.xch_page_size =3D PAGE_SIZE; @@ -423,7 +424,7 @@ xc_domain_dumpcore_via_callback(xc_interface *xch, void *args, dumpcore_rtn_t dump_rtn) { - xc_dominfo_t info; + xc_domaininfo_t info; shared_info_any_t *live_shinfo =3D NULL; struct domain_info_context _dinfo =3D {}; struct domain_info_context *dinfo =3D &_dinfo; @@ -468,15 +469,15 @@ xc_domain_dumpcore_via_callback(xc_interface *xch, goto out; } =20 - if ( xc_domain_getinfo(xch, domid, 1, &info) !=3D 1 ) + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) { - PERROR("Could not get info for domain"); + PERROR("Could not get info for dom%u", domid); goto out; } /* Map the shared info frame */ live_shinfo =3D xc_map_foreign_range(xch, domid, PAGE_SIZE, PROT_READ, info.shared_info_frame); - if ( !live_shinfo && !info.hvm ) + if ( !live_shinfo && !(info.flags & XEN_DOMINF_hvm_guest) ) { PERROR("Couldn't map live_shinfo"); goto out; @@ -517,12 +518,6 @@ xc_domain_dumpcore_via_callback(xc_interface *xch, dinfo->guest_width =3D sizeof(unsigned long); } =20 - if ( domid !=3D info.domid ) - { - PERROR("Domain %d does not exist", domid); - goto out; - } - ctxt =3D calloc(sizeof(*ctxt), info.max_vcpu_id + 1); if ( !ctxt ) { @@ -560,9 +555,9 @@ xc_domain_dumpcore_via_callback(xc_interface *xch, * all the array... * * We don't want to use the total potential size of the memory map - * since that is usually much higher than info.nr_pages. + * since that is usually much higher than info.tot_pages. */ - nr_pages =3D info.nr_pages; + nr_pages =3D info.tot_pages; =20 if ( !auto_translated_physmap ) { diff --git a/tools/libs/guest/xg_core.h b/tools/libs/guest/xg_core.h index aaca9e0a8b..ff577dad31 100644 --- a/tools/libs/guest/xg_core.h +++ b/tools/libs/guest/xg_core.h @@ -134,15 +134,15 @@ typedef struct xc_core_memory_map xc_core_memory_map_= t; struct xc_core_arch_context; int xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *arch_ctxt, - xc_dominfo_t *info, shared_info_any_t *liv= e_shinfo, + xc_domaininfo_t *info, shared_info_any_t *= live_shinfo, xc_core_memory_map_t **mapp, unsigned int *nr_entries); int xc_core_arch_map_p2m(xc_interface *xch, struct domain_info_context *di= nfo, - xc_dominfo_t *info, shared_info_any_t *live_shinf= o, + xc_domaininfo_t *info, shared_info_any_t *live_sh= info, xen_pfn_t **live_p2m); =20 int xc_core_arch_map_p2m_writable(xc_interface *xch, struct domain_info_co= ntext *dinfo, - xc_dominfo_t *info, + xc_domaininfo_t *info, shared_info_any_t *live_shinfo, xen_pfn_t **live_p2m); =20 diff --git a/tools/libs/guest/xg_core_arm.c b/tools/libs/guest/xg_core_arm.c index de30cf0c31..34276152da 100644 --- a/tools/libs/guest/xg_core_arm.c +++ b/tools/libs/guest/xg_core_arm.c @@ -33,14 +33,14 @@ xc_core_arch_gpfn_may_present(struct xc_core_arch_conte= xt *arch_ctxt, =20 int xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context= *unused, - xc_dominfo_t *info, shared_info_any_t *live_sh= info, + xc_domaininfo_t *info, shared_info_any_t *live= _shinfo, xc_core_memory_map_t **mapp, unsigned int *nr_entries) { xen_pfn_t p2m_size =3D 0; xc_core_memory_map_t *map; =20 - if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 ) + if ( xc_domain_nr_gpfns(xch, info->domain, &p2m_size) < 0 ) return -1; =20 map =3D malloc(sizeof(*map)); @@ -59,7 +59,7 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct xc_= core_arch_context *unus } =20 static int -xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *din= fo, xc_dominfo_t *info, +xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *din= fo, xc_domaininfo_t *info, shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m, int rw) { errno =3D ENOSYS; @@ -67,14 +67,14 @@ xc_core_arch_map_p2m_rw(xc_interface *xch, struct domai= n_info_context *dinfo, xc } =20 int -xc_core_arch_map_p2m(xc_interface *xch, struct domain_info_context *dinfo,= xc_dominfo_t *info, +xc_core_arch_map_p2m(xc_interface *xch, struct domain_info_context *dinfo,= xc_domaininfo_t *info, shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m) { return xc_core_arch_map_p2m_rw(xch, dinfo, info, live_shinfo, live_p2m= , 0); } =20 int -xc_core_arch_map_p2m_writable(xc_interface *xch, struct domain_info_contex= t *dinfo, xc_dominfo_t *info, +xc_core_arch_map_p2m_writable(xc_interface *xch, struct domain_info_contex= t *dinfo, xc_domaininfo_t *info, shared_info_any_t *live_shinfo, xen_pfn_t **= live_p2m) { return xc_core_arch_map_p2m_rw(xch, dinfo, info, live_shinfo, live_p2m= , 1); diff --git a/tools/libs/guest/xg_core_x86.c b/tools/libs/guest/xg_core_x86.c index c5e4542ccc..dbd3a440f7 100644 --- a/tools/libs/guest/xg_core_x86.c +++ b/tools/libs/guest/xg_core_x86.c @@ -49,14 +49,14 @@ xc_core_arch_gpfn_may_present(struct xc_core_arch_conte= xt *arch_ctxt, =20 int xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context= *unused, - xc_dominfo_t *info, shared_info_any_t *live_sh= info, + xc_domaininfo_t *info, shared_info_any_t *live= _shinfo, xc_core_memory_map_t **mapp, unsigned int *nr_entries) { xen_pfn_t p2m_size =3D 0; xc_core_memory_map_t *map; =20 - if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 ) + if ( xc_domain_nr_gpfns(xch, info->domain, &p2m_size) < 0 ) return -1; =20 map =3D malloc(sizeof(*map)); @@ -314,24 +314,24 @@ xc_core_arch_map_p2m_tree_rw(xc_interface *xch, struc= t domain_info_context *dinf } =20 static int -xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *din= fo, xc_dominfo_t *info, +xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *din= fo, xc_domaininfo_t *info, shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m, int rw) { xen_pfn_t *p2m_frame_list =3D NULL; uint64_t p2m_cr3; - uint32_t dom =3D info->domid; + uint32_t dom =3D info->domain; int ret =3D -1; int err; =20 - if ( xc_domain_nr_gpfns(xch, info->domid, &dinfo->p2m_size) < 0 ) + if ( xc_domain_nr_gpfns(xch, info->domain, &dinfo->p2m_size) < 0 ) { ERROR("Could not get maximum GPFN!"); goto out; } =20 - if ( dinfo->p2m_size < info->nr_pages ) + if ( dinfo->p2m_size < info->tot_pages ) { - ERROR("p2m_size < nr_pages -1 (%lx < %lx", dinfo->p2m_size, info->= nr_pages - 1); + ERROR("p2m_size < nr_pages -1 (%lx < %"PRIx64, dinfo->p2m_size, in= fo->tot_pages - 1); goto out; } =20 @@ -366,14 +366,14 @@ out: } =20 int -xc_core_arch_map_p2m(xc_interface *xch, struct domain_info_context *dinfo,= xc_dominfo_t *info, +xc_core_arch_map_p2m(xc_interface *xch, struct domain_info_context *dinfo,= xc_domaininfo_t *info, shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m) { return xc_core_arch_map_p2m_rw(xch, dinfo, info, live_shinfo, live_p2m= , 0); } =20 int -xc_core_arch_map_p2m_writable(xc_interface *xch, struct domain_info_contex= t *dinfo, xc_dominfo_t *info, +xc_core_arch_map_p2m_writable(xc_interface *xch, struct domain_info_contex= t *dinfo, xc_domaininfo_t *info, shared_info_any_t *live_shinfo, xen_pfn_t **= live_p2m) { return xc_core_arch_map_p2m_rw(xch, dinfo, info, live_shinfo, live_p2m= , 1); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index bd16a87e48..57221ffea8 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -281,7 +281,8 @@ static int xc_cpuid_xend_policy( xc_interface *xch, uint32_t domid, const struct xc_xend_cpuid *xend) { int rc; - xc_dominfo_t di; + bool hvm; + xc_domaininfo_t di; unsigned int nr_leaves, nr_msrs; uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; /* @@ -291,13 +292,13 @@ static int xc_cpuid_xend_policy( xen_cpuid_leaf_t *host =3D NULL, *def =3D NULL, *cur =3D NULL; unsigned int nr_host, nr_def, nr_cur; =20 - if ( xc_domain_getinfo(xch, domid, 1, &di) !=3D 1 || - di.domid !=3D domid ) + if ( (rc =3D xc_domain_getinfo_single(xch, domid, &di)) < 0 ) { - ERROR("Failed to obtain d%d info", domid); - rc =3D -ESRCH; + PERROR("Failed to obtain d%d info", domid); + rc =3D -errno; goto fail; } + hvm =3D di.flags & XEN_DOMINF_hvm_guest; =20 rc =3D xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs); if ( rc ) @@ -330,12 +331,12 @@ static int xc_cpuid_xend_policy( /* Get the domain type's default policy. */ nr_msrs =3D 0; nr_def =3D nr_leaves; - rc =3D get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault - : XEN_SYSCTL_cpu_policy_pv_defa= ult, + rc =3D get_system_cpu_policy(xch, hvm ? XEN_SYSCTL_cpu_policy_hvm_defa= ult + : XEN_SYSCTL_cpu_policy_pv_default, &nr_def, def, &nr_msrs, NULL); if ( rc ) { - PERROR("Failed to obtain %s def policy", di.hvm ? "hvm" : "pv"); + PERROR("Failed to obtain %s def policy", hvm ? "hvm" : "pv"); rc =3D -errno; goto fail; } @@ -428,7 +429,8 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, bool restore, const struct xc_xend_cpuid *xend) { int rc; - xc_dominfo_t di; + bool hvm; + xc_domaininfo_t di; unsigned int i, nr_leaves, nr_msrs; xen_cpuid_leaf_t *leaves =3D NULL; struct cpu_policy *p =3D NULL; @@ -436,13 +438,13 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t= domid, bool restore, uint32_t host_featureset[FEATURESET_NR_ENTRIES] =3D {}; uint32_t len =3D ARRAY_SIZE(host_featureset); =20 - if ( xc_domain_getinfo(xch, domid, 1, &di) !=3D 1 || - di.domid !=3D domid ) + if ( (rc =3D xc_domain_getinfo_single(xch, domid, &di)) < 0 ) { - ERROR("Failed to obtain d%d info", domid); - rc =3D -ESRCH; + PERROR("Failed to obtain d%d info", domid); + rc =3D -errno; goto out; } + hvm =3D di.flags & XEN_DOMINF_hvm_guest; =20 rc =3D xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs); if ( rc ) @@ -475,12 +477,12 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t= domid, bool restore, =20 /* Get the domain's default policy. */ nr_msrs =3D 0; - rc =3D get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault - : XEN_SYSCTL_cpu_policy_pv_defa= ult, + rc =3D get_system_cpu_policy(xch, hvm ? XEN_SYSCTL_cpu_policy_hvm_defa= ult + : XEN_SYSCTL_cpu_policy_pv_default, &nr_leaves, leaves, &nr_msrs, NULL); if ( rc ) { - PERROR("Failed to obtain %s default policy", di.hvm ? "hvm" : "pv"= ); + PERROR("Failed to obtain %s default policy", hvm ? "hvm" : "pv"); rc =3D -errno; goto out; } @@ -514,7 +516,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, bool restore, p->feat.hle =3D test_bit(X86_FEATURE_HLE, host_featureset); p->feat.rtm =3D test_bit(X86_FEATURE_RTM, host_featureset); =20 - if ( di.hvm ) + if ( hvm ) { p->feat.mpx =3D test_bit(X86_FEATURE_MPX, host_featureset); } @@ -571,7 +573,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, bool restore, { p->extd.itsc =3D itsc; =20 - if ( di.hvm ) + if ( hvm ) { p->basic.pae =3D pae; p->basic.vmx =3D nested_virt; @@ -579,7 +581,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, bool restore, } } =20 - if ( !di.hvm ) + if ( !hvm ) { /* * On hardware without CPUID Faulting, PV guests see real topology. diff --git a/tools/libs/guest/xg_dom_boot.c b/tools/libs/guest/xg_dom_boot.c index 263a3f4c85..6e0847e718 100644 --- a/tools/libs/guest/xg_dom_boot.c +++ b/tools/libs/guest/xg_dom_boot.c @@ -164,7 +164,7 @@ void *xc_dom_boot_domU_map(struct xc_dom_image *dom, xe= n_pfn_t pfn, =20 int xc_dom_boot_image(struct xc_dom_image *dom) { - xc_dominfo_t info; + xc_domaininfo_t info; int rc; =20 DOMPRINTF_CALLED(dom->xch); @@ -174,19 +174,11 @@ int xc_dom_boot_image(struct xc_dom_image *dom) return rc; =20 /* collect some info */ - rc =3D xc_domain_getinfo(dom->xch, dom->guest_domid, 1, &info); - if ( rc < 0 ) - { - xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, - "%s: getdomaininfo failed (rc=3D%d)", __FUNCTION__, r= c); - return rc; - } - if ( rc =3D=3D 0 || info.domid !=3D dom->guest_domid ) + if ( xc_domain_getinfo_single(dom->xch, dom->guest_domid, &info) < 0 ) { xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, - "%s: Huh? No domains found (nr_domains=3D%d) " - "or domid mismatch (%d !=3D %d)", __FUNCTION__, - rc, info.domid, dom->guest_domid); + "%s: getdomaininfo failed (errno=3D%d)", + __func__, errno); return -1; } dom->shared_info_mfn =3D info.shared_info_frame; diff --git a/tools/libs/guest/xg_domain.c b/tools/libs/guest/xg_domain.c index f0e7748449..198f6f904a 100644 --- a/tools/libs/guest/xg_domain.c +++ b/tools/libs/guest/xg_domain.c @@ -37,7 +37,7 @@ int xc_map_domain_meminfo(xc_interface *xch, uint32_t dom= id, { struct domain_info_context _di; =20 - xc_dominfo_t info; + xc_domaininfo_t info; shared_info_any_t *live_shinfo; xen_capabilities_info_t xen_caps =3D ""; unsigned long i; @@ -49,9 +49,9 @@ int xc_map_domain_meminfo(xc_interface *xch, uint32_t dom= id, return -1; } =20 - if ( xc_domain_getinfo(xch, domid, 1, &info) !=3D 1 ) + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) { - PERROR("Could not get domain info"); + PERROR("Could not get dominfo for dom%u", domid); return -1; } =20 @@ -86,7 +86,7 @@ int xc_map_domain_meminfo(xc_interface *xch, uint32_t dom= id, info.shared_info_frame); if ( !live_shinfo ) { - PERROR("Could not map the shared info frame (MFN 0x%lx)", + PERROR("Could not map the shared info frame (MFN 0x%"PRIx64")", info.shared_info_frame); return -1; } diff --git a/tools/libs/guest/xg_offline_page.c b/tools/libs/guest/xg_offli= ne_page.c index 8f0a252417..5f61d49456 100644 --- a/tools/libs/guest/xg_offline_page.c +++ b/tools/libs/guest/xg_offline_page.c @@ -366,7 +366,7 @@ static int clear_pte(xc_interface *xch, uint32_t domid, */ =20 static int is_page_exchangable(xc_interface *xch, uint32_t domid, xen_pfn_= t mfn, - xc_dominfo_t *info) + xc_domaininfo_t *info) { uint32_t status; int rc; @@ -377,7 +377,7 @@ static int is_page_exchangable(xc_interface *xch, uint3= 2_t domid, xen_pfn_t mfn, DPRINTF("Dom0's page can't be LM"); return 0; } - if (info->hvm) + if (info->flags & XEN_DOMINF_hvm_guest) { DPRINTF("Currently we can only live change PV guest's page\n"); return 0; @@ -458,7 +458,7 @@ err0: /* The domain should be suspended when called here */ int xc_exchange_page(xc_interface *xch, uint32_t domid, xen_pfn_t mfn) { - xc_dominfo_t info; + xc_domaininfo_t info; struct xc_domain_meminfo minfo; struct xc_mmu *mmu =3D NULL; struct pte_backup old_ptes =3D {NULL, 0, 0}; @@ -473,13 +473,13 @@ int xc_exchange_page(xc_interface *xch, uint32_t domi= d, xen_pfn_t mfn) xen_pfn_t *m2p_table; unsigned long max_mfn; =20 - if ( xc_domain_getinfo(xch, domid, 1, &info) !=3D 1 ) + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) { - ERROR("Could not get domain info"); + PERROR("Could not get domain info for dom%u", domid); return -1; } =20 - if (!info.shutdown || info.shutdown_reason !=3D SHUTDOWN_suspend) + if (!dominfo_shutdown_with(&info, SHUTDOWN_suspend)) { errno =3D EINVAL; ERROR("Can't exchange page unless domain is suspended\n"); diff --git a/tools/libs/guest/xg_private.h b/tools/libs/guest/xg_private.h index e729a8106c..d73947094f 100644 --- a/tools/libs/guest/xg_private.h +++ b/tools/libs/guest/xg_private.h @@ -16,6 +16,7 @@ #ifndef XG_PRIVATE_H #define XG_PRIVATE_H =20 +#include #include #include #include diff --git a/tools/libs/guest/xg_resume.c b/tools/libs/guest/xg_resume.c index 77e2451a3c..c85d09a7f5 100644 --- a/tools/libs/guest/xg_resume.c +++ b/tools/libs/guest/xg_resume.c @@ -26,28 +26,28 @@ static int modify_returncode(xc_interface *xch, uint32_t domid) { vcpu_guest_context_any_t ctxt; - xc_dominfo_t info; + xc_domaininfo_t info; xen_capabilities_info_t caps; struct domain_info_context _dinfo =3D {}; struct domain_info_context *dinfo =3D &_dinfo; int rc; =20 - if ( xc_domain_getinfo(xch, domid, 1, &info) !=3D 1 || - info.domid !=3D domid ) + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) { - PERROR("Could not get domain info"); + PERROR("Could not get info for dom%u", domid); return -1; } =20 - if ( !info.shutdown || (info.shutdown_reason !=3D SHUTDOWN_suspend) ) + if ( !dominfo_shutdown_with(&info, SHUTDOWN_suspend) ) { ERROR("Dom %d not suspended: (shutdown %d, reason %d)", domid, - info.shutdown, info.shutdown_reason); + info.flags & XEN_DOMINF_shutdown, + dominfo_shutdown_reason(&info)); errno =3D EINVAL; return -1; } =20 - if ( info.hvm ) + if ( info.flags & XEN_DOMINF_hvm_guest ) { /* HVM guests without PV drivers have no return code to modify. */ uint64_t irq =3D 0; @@ -133,7 +133,7 @@ static int xc_domain_resume_hvm(xc_interface *xch, uint= 32_t domid) static int xc_domain_resume_any(xc_interface *xch, uint32_t domid) { DECLARE_DOMCTL; - xc_dominfo_t info; + xc_domaininfo_t info; int i, rc =3D -1; #if defined(__i386__) || defined(__x86_64__) struct domain_info_context _dinfo =3D { .guest_width =3D 0, @@ -146,7 +146,7 @@ static int xc_domain_resume_any(xc_interface *xch, uint= 32_t domid) xen_pfn_t *p2m =3D NULL; #endif =20 - if ( xc_domain_getinfo(xch, domid, 1, &info) !=3D 1 ) + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) { PERROR("Could not get domain info"); return rc; @@ -156,7 +156,7 @@ static int xc_domain_resume_any(xc_interface *xch, uint= 32_t domid) * (x86 only) Rewrite store_mfn and console_mfn back to MFN (from PFN). */ #if defined(__i386__) || defined(__x86_64__) - if ( info.hvm ) + if ( info.flags & XEN_DOMINF_hvm_guest ) return xc_domain_resume_hvm(xch, domid); =20 if ( xc_domain_get_guest_width(xch, domid, &dinfo->guest_width) !=3D 0= ) diff --git a/tools/libs/guest/xg_sr_common.h b/tools/libs/guest/xg_sr_commo= n.h index 36d45ef56f..2f058ee3a6 100644 --- a/tools/libs/guest/xg_sr_common.h +++ b/tools/libs/guest/xg_sr_common.h @@ -220,7 +220,7 @@ struct xc_sr_context /* Plain VM, or checkpoints over time. */ xc_stream_type_t stream_type; =20 - xc_dominfo_t dominfo; + xc_domaininfo_t dominfo; =20 union /* Common save or restore data. */ { diff --git a/tools/libs/guest/xg_sr_restore.c b/tools/libs/guest/xg_sr_rest= ore.c index 7314a24cf9..06231ca826 100644 --- a/tools/libs/guest/xg_sr_restore.c +++ b/tools/libs/guest/xg_sr_restore.c @@ -852,6 +852,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uin= t32_t dom, xc_stream_type_t stream_type, struct restore_callbacks *callbacks, int send_back_f= d) { + bool hvm; xen_pfn_t nr_pfns; struct xc_sr_context ctx =3D { .xch =3D xch, @@ -887,20 +888,15 @@ int xc_domain_restore(xc_interface *xch, int io_fd, u= int32_t dom, break; } =20 - if ( xc_domain_getinfo(xch, dom, 1, &ctx.dominfo) !=3D 1 ) + if ( xc_domain_getinfo_single(xch, dom, &ctx.dominfo) < 0 ) { - PERROR("Failed to get domain info"); - return -1; - } - - if ( ctx.dominfo.domid !=3D dom ) - { - ERROR("Domain %u does not exist", dom); + PERROR("Failed to get dominfo for dom%u", dom); return -1; } =20 + hvm =3D ctx.dominfo.flags & XEN_DOMINF_hvm_guest; DPRINTF("fd %d, dom %u, hvm %u, stream_type %d", - io_fd, dom, ctx.dominfo.hvm, stream_type); + io_fd, dom, hvm, stream_type); =20 ctx.domid =3D dom; =20 @@ -914,8 +910,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uin= t32_t dom, } =20 ctx.restore.p2m_size =3D nr_pfns; - ctx.restore.ops =3D ctx.dominfo.hvm - ? restore_ops_x86_hvm : restore_ops_x86_pv; + ctx.restore.ops =3D hvm ? restore_ops_x86_hvm : restore_ops_x86_pv; =20 if ( restore(&ctx) ) return -1; diff --git a/tools/libs/guest/xg_sr_restore_x86_pv.c b/tools/libs/guest/xg_= sr_restore_x86_pv.c index dc50b0f5a8..eaeb97f4a0 100644 --- a/tools/libs/guest/xg_sr_restore_x86_pv.c +++ b/tools/libs/guest/xg_sr_restore_x86_pv.c @@ -903,7 +903,7 @@ static int handle_shared_info(struct xc_sr_context *ctx, ctx->dominfo.shared_info_frame); if ( !guest_shinfo ) { - PERROR("Failed to map Shared Info at mfn %#lx", + PERROR("Failed to map Shared Info at mfn %#"PRIx64, ctx->dominfo.shared_info_frame); goto err; } diff --git a/tools/libs/guest/xg_sr_save.c b/tools/libs/guest/xg_sr_save.c index 9853d8d846..3b2c5222e4 100644 --- a/tools/libs/guest/xg_sr_save.c +++ b/tools/libs/guest/xg_sr_save.c @@ -336,19 +336,18 @@ static int suspend_domain(struct xc_sr_context *ctx) } =20 /* Refresh domain information. */ - if ( (xc_domain_getinfo(xch, ctx->domid, 1, &ctx->dominfo) !=3D 1) || - (ctx->dominfo.domid !=3D ctx->domid) ) + if ( xc_domain_getinfo_single(xch, ctx->domid, &ctx->dominfo) < 0 ) { PERROR("Unable to refresh domain information"); return -1; } =20 /* Confirm the domain has actually been paused. */ - if ( !ctx->dominfo.shutdown || - (ctx->dominfo.shutdown_reason !=3D SHUTDOWN_suspend) ) + if ( !dominfo_shutdown_with(&ctx->dominfo, SHUTDOWN_suspend) ) { ERROR("Domain has not been suspended: shutdown %d, reason %d", - ctx->dominfo.shutdown, ctx->dominfo.shutdown_reason); + ctx->dominfo.flags & XEN_DOMINF_shutdown, + dominfo_shutdown_reason(&ctx->dominfo)); return -1; } =20 @@ -893,8 +892,7 @@ static int save(struct xc_sr_context *ctx, uint16_t gue= st_type) if ( rc ) goto err; =20 - if ( !ctx->dominfo.shutdown || - (ctx->dominfo.shutdown_reason !=3D SHUTDOWN_suspend) ) + if ( !dominfo_shutdown_with(&ctx->dominfo, SHUTDOWN_suspend) ) { ERROR("Domain has not been suspended"); rc =3D -1; @@ -989,6 +987,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32= _t dom, .fd =3D io_fd, .stream_type =3D stream_type, }; + bool hvm; =20 /* GCC 4.4 (of CentOS 6.x vintage) can' t initialise anonymous unions.= */ ctx.save.callbacks =3D callbacks; @@ -996,17 +995,13 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint= 32_t dom, ctx.save.debug =3D !!(flags & XCFLAGS_DEBUG); ctx.save.recv_fd =3D recv_fd; =20 - if ( xc_domain_getinfo(xch, dom, 1, &ctx.dominfo) !=3D 1 ) + if ( xc_domain_getinfo_single(xch, dom, &ctx.dominfo) < 0 ) { PERROR("Failed to get domain info"); return -1; } =20 - if ( ctx.dominfo.domid !=3D dom ) - { - ERROR("Domain %u does not exist", dom); - return -1; - } + hvm =3D ctx.dominfo.flags & XEN_DOMINF_hvm_guest; =20 /* Sanity check stream_type-related parameters */ switch ( stream_type ) @@ -1018,7 +1013,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint= 32_t dom, assert(callbacks->checkpoint && callbacks->postcopy); /* Fallthrough */ case XC_STREAM_PLAIN: - if ( ctx.dominfo.hvm ) + if ( hvm ) assert(callbacks->switch_qemu_logdirty); break; =20 @@ -1028,11 +1023,11 @@ int xc_domain_save(xc_interface *xch, int io_fd, ui= nt32_t dom, } =20 DPRINTF("fd %d, dom %u, flags %u, hvm %d", - io_fd, dom, flags, ctx.dominfo.hvm); + io_fd, dom, flags, hvm); =20 ctx.domid =3D dom; =20 - if ( ctx.dominfo.hvm ) + if ( hvm ) { ctx.save.ops =3D save_ops_x86_hvm; return save(&ctx, DHDR_TYPE_X86_HVM); diff --git a/tools/libs/guest/xg_sr_save_x86_pv.c b/tools/libs/guest/xg_sr_= save_x86_pv.c index 4964f1f7b8..f3d7a7a71a 100644 --- a/tools/libs/guest/xg_sr_save_x86_pv.c +++ b/tools/libs/guest/xg_sr_save_x86_pv.c @@ -20,7 +20,7 @@ static int map_shinfo(struct xc_sr_context *ctx) xch, ctx->domid, PAGE_SIZE, PROT_READ, ctx->dominfo.shared_info_fr= ame); if ( !ctx->x86.pv.shinfo ) { - PERROR("Failed to map shared info frame at mfn %#lx", + PERROR("Failed to map shared info frame at mfn %#"PRIx64, ctx->dominfo.shared_info_frame); return -1; } @@ -943,7 +943,7 @@ static int normalise_pagetable(struct xc_sr_context *ct= x, const uint64_t *src, #ifdef __i386__ if ( mfn =3D=3D INVALID_MFN ) { - if ( !ctx->dominfo.paused ) + if ( !(ctx->dominfo.flags & XEN_DOMINF_paused) ) errno =3D EAGAIN; else { @@ -965,7 +965,7 @@ static int normalise_pagetable(struct xc_sr_context *ct= x, const uint64_t *src, =20 if ( !mfn_in_pseudophysmap(ctx, mfn) ) { - if ( !ctx->dominfo.paused ) + if ( !(ctx->dominfo.flags & XEN_DOMINF_paused) ) errno =3D EAGAIN; else { diff --git a/tools/libs/light/libxl_sched.c b/tools/libs/light/libxl_sched.c index 841c05b0ef..2d6635dae7 100644 --- a/tools/libs/light/libxl_sched.c +++ b/tools/libs/light/libxl_sched.c @@ -498,10 +498,10 @@ static int sched_rtds_vcpu_get(libxl__gc *gc, uint32_= t domid, { uint32_t num_vcpus; int i, r, rc; - xc_dominfo_t info; + xc_domaininfo_t info; struct xen_domctl_schedparam_vcpu *vcpus; =20 - r =3D xc_domain_getinfo(CTX->xch, domid, 1, &info); + r =3D xc_domain_getinfo_single(CTX->xch, domid, &info); if (r < 0) { LOGED(ERROR, domid, "Getting domain info"); rc =3D ERROR_FAIL; @@ -552,10 +552,10 @@ static int sched_rtds_vcpu_get_all(libxl__gc *gc, uin= t32_t domid, { uint32_t num_vcpus; int i, r, rc; - xc_dominfo_t info; + xc_domaininfo_t info; struct xen_domctl_schedparam_vcpu *vcpus; =20 - r =3D xc_domain_getinfo(CTX->xch, domid, 1, &info); + r =3D xc_domain_getinfo_single(CTX->xch, domid, &info); if (r < 0) { LOGED(ERROR, domid, "Getting domain info"); rc =3D ERROR_FAIL; @@ -602,10 +602,10 @@ static int sched_rtds_vcpu_set(libxl__gc *gc, uint32_= t domid, int r, rc; int i; uint16_t max_vcpuid; - xc_dominfo_t info; + xc_domaininfo_t info; struct xen_domctl_schedparam_vcpu *vcpus; =20 - r =3D xc_domain_getinfo(CTX->xch, domid, 1, &info); + r =3D xc_domain_getinfo_single(CTX->xch, domid, &info); if (r < 0) { LOGED(ERROR, domid, "Getting domain info"); rc =3D ERROR_FAIL; @@ -662,11 +662,11 @@ static int sched_rtds_vcpu_set_all(libxl__gc *gc, uin= t32_t domid, int r, rc; int i; uint16_t max_vcpuid; - xc_dominfo_t info; + xc_domaininfo_t info; struct xen_domctl_schedparam_vcpu *vcpus; uint32_t num_vcpus; =20 - r =3D xc_domain_getinfo(CTX->xch, domid, 1, &info); + r =3D xc_domain_getinfo_single(CTX->xch, domid, &info); if (r < 0) { LOGED(ERROR, domid, "Getting domain info"); rc =3D ERROR_FAIL; diff --git a/tools/libs/light/libxl_x86_acpi.c b/tools/libs/light/libxl_x86= _acpi.c index 22eb160659..620f3c700c 100644 --- a/tools/libs/light/libxl_x86_acpi.c +++ b/tools/libs/light/libxl_x86_acpi.c @@ -87,16 +87,16 @@ static int init_acpi_config(libxl__gc *gc, { xc_interface *xch =3D dom->xch; uint32_t domid =3D dom->guest_domid; - xc_dominfo_t info; + xc_domaininfo_t info; struct hvm_info_table *hvminfo; int i, r, rc; =20 config->dsdt_anycpu =3D config->dsdt_15cpu =3D dsdt_pvh; config->dsdt_anycpu_len =3D config->dsdt_15cpu_len =3D dsdt_pvh_len; =20 - r =3D xc_domain_getinfo(xch, domid, 1, &info); + r =3D xc_domain_getinfo_single(xch, domid, &info); if (r < 0) { - LOG(ERROR, "getdomaininfo failed (rc=3D%d)", r); + LOGED(ERROR, domid, "getdomaininfo failed"); rc =3D ERROR_FAIL; goto out; } diff --git a/tools/misc/xen-hvmcrash.c b/tools/misc/xen-hvmcrash.c index 4f0dabcb18..1d058fa40a 100644 --- a/tools/misc/xen-hvmcrash.c +++ b/tools/misc/xen-hvmcrash.c @@ -48,7 +48,7 @@ main(int argc, char **argv) { int domid; xc_interface *xch; - xc_dominfo_t dominfo; + xc_domaininfo_t dominfo; int ret; uint32_t len; uint8_t *buf; @@ -66,13 +66,13 @@ main(int argc, char **argv) exit(1); } =20 - ret =3D xc_domain_getinfo(xch, domid, 1, &dominfo); + ret =3D xc_domain_getinfo_single(xch, domid, &dominfo); if (ret < 0) { perror("xc_domain_getinfo"); exit(1); } =20 - if (!dominfo.hvm) { + if (!(dominfo.flags & XEN_DOMINF_hvm_guest)) { fprintf(stderr, "domain %d is not HVM\n", domid); exit(1); } diff --git a/tools/misc/xen-lowmemd.c b/tools/misc/xen-lowmemd.c index a3a2741242..9d5cb549a8 100644 --- a/tools/misc/xen-lowmemd.c +++ b/tools/misc/xen-lowmemd.c @@ -38,7 +38,7 @@ void cleanup(void) #define BUFSZ 512 void handle_low_mem(void) { - xc_dominfo_t dom0_info; + xc_domaininfo_t dom0_info; xc_physinfo_t info; unsigned long long free_pages, dom0_pages, diff, dom0_target; char data[BUFSZ], error[BUFSZ]; @@ -58,13 +58,13 @@ void handle_low_mem(void) return; diff =3D THRESHOLD_PG - free_pages;=20 =20 - if (xc_domain_getinfo(xch, 0, 1, &dom0_info) < 1) + if (xc_domain_getinfo_single(xch, 0, &dom0_info) < 0) { perror("Failed to get dom0 info"); return; } =20 - dom0_pages =3D (unsigned long long) dom0_info.nr_pages; + dom0_pages =3D (unsigned long long) dom0_info.tot_pages; printf("Dom0 pages: 0x%llx:%llu\n", dom0_pages, dom0_pages); dom0_target =3D dom0_pages - diff; if (dom0_target <=3D DOM0_FLOOR_PG) diff --git a/tools/misc/xen-mfndump.c b/tools/misc/xen-mfndump.c index b32c95e262..8863ece3f5 100644 --- a/tools/misc/xen-mfndump.c +++ b/tools/misc/xen-mfndump.c @@ -74,7 +74,7 @@ int dump_m2p_func(int argc, char *argv[]) int dump_p2m_func(int argc, char *argv[]) { struct xc_domain_meminfo minfo; - xc_dominfo_t info; + xc_domaininfo_t info; unsigned long i; int domid; =20 @@ -85,8 +85,7 @@ int dump_p2m_func(int argc, char *argv[]) } domid =3D atoi(argv[0]); =20 - if ( xc_domain_getinfo(xch, domid, 1, &info) !=3D 1 || - info.domid !=3D domid ) + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) { ERROR("Failed to obtain info for domain %d\n", domid); return -1; @@ -158,7 +157,7 @@ int dump_p2m_func(int argc, char *argv[]) int dump_ptes_func(int argc, char *argv[]) { struct xc_domain_meminfo minfo; - xc_dominfo_t info; + xc_domaininfo_t info; void *page =3D NULL; unsigned long i, max_mfn; int domid, pte_num, rc =3D 0; @@ -172,8 +171,7 @@ int dump_ptes_func(int argc, char *argv[]) domid =3D atoi(argv[0]); mfn =3D strtoul(argv[1], NULL, 16); =20 - if ( xc_domain_getinfo(xch, domid, 1, &info) !=3D 1 || - info.domid !=3D domid ) + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) { ERROR("Failed to obtain info for domain %d\n", domid); return -1; @@ -266,7 +264,7 @@ int dump_ptes_func(int argc, char *argv[]) int lookup_pte_func(int argc, char *argv[]) { struct xc_domain_meminfo minfo; - xc_dominfo_t info; + xc_domaininfo_t info; void *page =3D NULL; unsigned long i, j; int domid, pte_num; @@ -280,8 +278,7 @@ int lookup_pte_func(int argc, char *argv[]) domid =3D atoi(argv[0]); mfn =3D strtoul(argv[1], NULL, 16); =20 - if ( xc_domain_getinfo(xch, domid, 1, &info) !=3D 1 || - info.domid !=3D domid ) + if ( xc_domain_getinfo_single(xch, domid, &info) < 0 ) { ERROR("Failed to obtain info for domain %d\n", domid); return -1; @@ -336,7 +333,7 @@ int lookup_pte_func(int argc, char *argv[]) =20 int memcmp_mfns_func(int argc, char *argv[]) { - xc_dominfo_t info1, info2; + xc_domaininfo_t info1, info2; void *page1 =3D NULL, *page2 =3D NULL; int domid1, domid2; xen_pfn_t mfn1, mfn2; @@ -352,9 +349,8 @@ int memcmp_mfns_func(int argc, char *argv[]) mfn1 =3D strtoul(argv[1], NULL, 16); mfn2 =3D strtoul(argv[3], NULL, 16); =20 - if ( xc_domain_getinfo(xch, domid1, 1, &info1) !=3D 1 || - xc_domain_getinfo(xch, domid2, 1, &info2) !=3D 1 || - info1.domid !=3D domid1 || info2.domid !=3D domid2) + if ( xc_domain_getinfo_single(xch, domid1, &info1) < 0 || + xc_domain_getinfo_single(xch, domid2, &info2) < 0) { ERROR("Failed to obtain info for domains\n"); return -1; diff --git a/tools/misc/xen-vmtrace.c b/tools/misc/xen-vmtrace.c index 5b688a54af..ba2ce17a17 100644 --- a/tools/misc/xen-vmtrace.c +++ b/tools/misc/xen-vmtrace.c @@ -133,15 +133,15 @@ int main(int argc, char **argv) =20 while ( !interrupted ) { - xc_dominfo_t dominfo; + xc_domaininfo_t dominfo; =20 if ( get_more_data() ) goto out; =20 usleep(1000 * 100); =20 - if ( xc_domain_getinfo(xch, domid, 1, &dominfo) !=3D 1 || - dominfo.domid !=3D domid || dominfo.shutdown ) + if ( xc_domain_getinfo_single(xch, domid, &dominfo) < 0 || + (dominfo.flags & XEN_DOMINF_shutdown) ) { if ( get_more_data() ) goto out; diff --git a/tools/vchan/vchan-socket-proxy.c b/tools/vchan/vchan-socket-pr= oxy.c index e1d959c6d1..9c4c336b03 100644 --- a/tools/vchan/vchan-socket-proxy.c +++ b/tools/vchan/vchan-socket-proxy.c @@ -222,7 +222,7 @@ static struct libxenvchan *connect_vchan(int domid, con= st char *path) { struct libxenvchan *ctrl =3D NULL; struct xs_handle *xs =3D NULL; xc_interface *xc =3D NULL; - xc_dominfo_t dominfo; + xc_domaininfo_t dominfo; char **watch_ret; unsigned int watch_num; int ret; @@ -254,12 +254,12 @@ static struct libxenvchan *connect_vchan(int domid, c= onst char *path) { if (ctrl) break; =20 - ret =3D xc_domain_getinfo(xc, domid, 1, &dominfo); + ret =3D xc_domain_getinfo_single(xc, domid, &dominfo); /* break the loop if domain is definitely not there anymore, but * continue if it is or the call failed (like EPERM) */ if (ret =3D=3D -1 && errno =3D=3D ESRCH) break; - if (ret =3D=3D 1 && (dominfo.domid !=3D (uint32_t)domid || dominfo= .dying)) + if (ret =3D=3D 0 && (dominfo.flags & XEN_DOMINF_dying)) break; } =20 diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index f62be2245c..aeb7595ae1 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -339,15 +339,14 @@ static int destroy_domain(void *_domain) return 0; } =20 -static bool get_domain_info(unsigned int domid, xc_dominfo_t *dominfo) +static bool get_domain_info(unsigned int domid, xc_domaininfo_t *dominfo) { - return xc_domain_getinfo(*xc_handle, domid, 1, dominfo) =3D=3D 1 && - dominfo->domid =3D=3D domid; + return xc_domain_getinfo_single(*xc_handle, domid, dominfo) =3D=3D 0; } =20 static int check_domain(const void *k, void *v, void *arg) { - xc_dominfo_t dominfo; + xc_domaininfo_t dominfo; struct connection *conn; bool dom_valid; struct domain *domain =3D v; @@ -360,12 +359,12 @@ static int check_domain(const void *k, void *v, void = *arg) return 0; } if (dom_valid) { - if ((dominfo.crashed || dominfo.shutdown) + if ((dominfo.flags & XEN_DOMINF_shutdown) && !domain->shutdown) { domain->shutdown =3D true; *notify =3D true; } - if (!dominfo.dying) + if (!(dominfo.flags & XEN_DOMINF_dying)) return 0; } if (domain->conn) { @@ -486,7 +485,7 @@ static struct domain *find_or_alloc_domain(const void *= ctx, unsigned int domid) static struct domain *find_or_alloc_existing_domain(unsigned int domid) { struct domain *domain; - xc_dominfo_t dominfo; + xc_domaininfo_t dominfo; =20 domain =3D find_domain_struct(domid); if (!domain && get_domain_info(domid, &dominfo)) @@ -1010,7 +1009,7 @@ int domain_alloc_permrefs(struct node_perms *perms) { unsigned int i, domid; struct domain *d; - xc_dominfo_t dominfo; + xc_domaininfo_t dominfo; =20 for (i =3D 0; i < perms->num; i++) { domid =3D perms->p[i].id; diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c index 85ba0c0fa6..9acb9db460 100644 --- a/tools/xentrace/xenctx.c +++ b/tools/xentrace/xenctx.c @@ -92,7 +92,7 @@ static struct xenctx { int do_stack; #endif int kernel_start_set; - xc_dominfo_t dominfo; + xc_domaininfo_t dominfo; } xenctx; =20 struct symbol { @@ -989,7 +989,7 @@ static void dump_ctx(int vcpu) =20 #if defined(__i386__) || defined(__x86_64__) { - if (xenctx.dominfo.hvm) { + if (xenctx.dominfo.flags & XEN_DOMINF_hvm_guest) { struct hvm_hw_cpu cpuctx; xen_capabilities_info_t xen_caps =3D ""; if (xc_domain_hvm_getcontext_partial( @@ -1269,9 +1269,9 @@ int main(int argc, char **argv) exit(-1); } =20 - ret =3D xc_domain_getinfo(xenctx.xc_handle, xenctx.domid, 1, &xenctx.d= ominfo); + ret =3D xc_domain_getinfo_single(xenctx.xc_handle, xenctx.domid, &xenc= tx.dominfo); if (ret < 0) { - perror("xc_domain_getinfo"); + perror("xc_domain_getinfo_single"); exit(-1); } =20 --=20 2.34.1 From nobody Tue May 14 11:51:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1683648469; cv=none; d=zohomail.com; s=zohoarc; b=drPCn+ROEPk1AW6lWsedYcxqNNIMIMu7e4SL4YO1U82l3ts72H6E1LROVVPHdWjBLZf5Q1aPV6MTUt/D6mmaol7dQFPnaYVr/qniPUZLlRHUD79aowbeKGxsOz5GueeObIg43AGl+3wcAXYwOR9Fckb/KuGeYlmuBHu4ptKw0zI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683648469; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mZVhaMLLt7izRTc4YEPKUAhksNrFYD80OOgYr+Bs30o=; b=H4k06OxsZkjOliy69Jp5zJ4AqPYuy5oA/MoBbMZUsjcc7YkN3K6XFPDtXqrb4dJa6czFNCPUmJ6Evr85nOHobpLjI8Dbzp4ocp/EwsIOIWpwCljHA+WuCxL4jknqt0fMoRIJNQmExX+lQIArrH6/ZdFYiwsEFeYGcUigQrIxCmQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1683648469261574.136844107834; Tue, 9 May 2023 09:07:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.532311.828471 (Exim 4.92) (envelope-from ) id 1pwPs7-0001YK-UZ; Tue, 09 May 2023 16:07:27 +0000 Received: by outflank-mailman (output) from mailman id 532311.828471; Tue, 09 May 2023 16:07:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pwPs7-0001Y9-QX; Tue, 09 May 2023 16:07:27 +0000 Received: by outflank-mailman (input) for mailman id 532311; Tue, 09 May 2023 16:07:27 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pwPs7-0001Fg-0g for xen-devel@lists.xenproject.org; Tue, 09 May 2023 16:07:27 +0000 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [2a00:1450:4864:20::434]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 94db335f-ee83-11ed-8611-37d641c3527e; Tue, 09 May 2023 18:07:22 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-307a8386946so565030f8f.2 for ; Tue, 09 May 2023 09:07:22 -0700 (PDT) Received: from localhost.localdomain (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id z8-20020adfec88000000b003062675d4c9sm14721479wrn.39.2023.05.09.09.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 09:07:20 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 94db335f-ee83-11ed-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1683648441; x=1686240441; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mZVhaMLLt7izRTc4YEPKUAhksNrFYD80OOgYr+Bs30o=; b=aSAZmNzDfEFZr0palmyTgXnZI3hyF2CBWvfryL4uVQHjVxl3BrtWVEmZdzwmYovvbp EzbcMl05CQf59eySp7c3sNvvqOnjUuzmyfJxUS+f5v1vlujJPcjz15zm+slcs6C0gqNN 5+NUQ6hfzVTKoRIaf/6xgUOCwdKV6R83Gyg9w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683648441; x=1686240441; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mZVhaMLLt7izRTc4YEPKUAhksNrFYD80OOgYr+Bs30o=; b=PNqBdetk7JHV01Pr4UNucSVyQeb+4cpegnXm/+ZHHOHFY7ZFFarm6f8Obz2cWh5hEv /qcEfRQVAuopBS8glsd1chZ6z01Y1OCJqXovw0PTk9eGZyY821sxEotWFeClF/fKDqnV fLvpTnAo2q+hCOX1XepIb3EIzI8Y/B74L5huPZlwVDeQquRz35ZOP7mXfB4hX0j4s0Vr dzneVDUttvLYVVRQAGuzqUQAiZ5bbmu0FBVMtkEfm1FFT4XG4Lpcd207SJwpqc3reRKW DSyx2OLoEHoz/pZHoaZNOdorinoKba9U9ADjFAcDBRFmvpheATxKmvX1SXSkNlLMFrpX zeTg== X-Gm-Message-State: AC+VfDzp7FIuuEMpqjFeE8blMkeQOtQ8FcqFG5BxXl/kuCvUib3TrJYS klNV6Dih/0mgOjkvXAT5IrdnuPVQup4bS9CIoHQ= X-Google-Smtp-Source: ACHHUZ4hST7B0s6Bpmr+TX+xyHq63ScfSVVrzgqYaS3Wc82T0K9gxOlyRi3zklQr+zUDJ0Xea2mZKg== X-Received: by 2002:a05:6000:1b8f:b0:306:2b31:5935 with SMTP id r15-20020a0560001b8f00b003062b315935mr8463700wru.55.1683648441777; Tue, 09 May 2023 09:07:21 -0700 (PDT) From: Alejandro Vallejo To: Xen-devel Cc: Alejandro Vallejo , Andrew Cooper , Anthony PERARD , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Juergen Gross Subject: [PATCH v4 3/3] domctl: Modify XEN_DOMCTL_getdomaininfo to fail if domid is not found Date: Tue, 9 May 2023 17:07:12 +0100 Message-Id: <20230509160712.11685-4-alejandro.vallejo@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509160712.11685-1-alejandro.vallejo@cloud.com> References: <20230509160712.11685-1-alejandro.vallejo@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1683648470343100003 Content-Type: text/plain; charset="utf-8" It previously mimicked the getdomaininfo sysctl semantics by returning the first domid higher than the requested domid that does exist. This unintuitive behaviour causes quite a few mistakes and makes the call needlessly slow in its error path. This patch removes the fallback search, returning -ESRCH if the requested domain doesn't exist. Domain discovery can still be done through the sysctl interface as that performs a linear search on the list of domains. With this modification the xc_domain_getinfo() function is deprecated and removed to make sure it's not mistakenly used expecting the old behaviour. The new xc wrapper is xc_domain_getinfo_single(). All previous callers of xc_domain_getinfo() have been updated to use xc_domain_getinfo_single() or xc_domain_getinfolist() instead. This also means xc_dominfo_t is no longer used by anything and can be purged. Resolves: xen-project/xen#105 Signed-off-by: Alejandro Vallejo Reviewed-by: Andrew Cooper Acked-by: Anthony PERARD --- Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/include/xenctrl.h | 43 ---------------------- tools/libs/ctrl/xc_domain.c | 73 ------------------------------------- xen/common/domctl.c | 32 +--------------- 3 files changed, 2 insertions(+), 146 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 086314d28a..dba33d5d0f 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -444,28 +444,6 @@ typedef struct xc_core_header { * DOMAIN MANAGEMENT FUNCTIONS */ =20 -typedef struct xc_dominfo { - uint32_t domid; - uint32_t ssidref; - unsigned int dying:1, crashed:1, shutdown:1, - paused:1, blocked:1, running:1, - hvm:1, debugged:1, xenstore:1, hap:1; - unsigned int shutdown_reason; /* only meaningful if shutdown=3D=3D1 */ - unsigned long nr_pages; /* current number, not maximum */ - unsigned long nr_outstanding_pages; - unsigned long nr_shared_pages; - unsigned long nr_paged_pages; - unsigned long shared_info_frame; - uint64_t cpu_time; - unsigned long max_memkb; - unsigned int nr_online_vcpus; - unsigned int max_vcpu_id; - xen_domain_handle_t handle; - unsigned int cpupool; - uint8_t gpaddr_bits; - struct xen_arch_domainconfig arch_config; -} xc_dominfo_t; - typedef xen_domctl_getdomaininfo_t xc_domaininfo_t; =20 static inline unsigned int dominfo_shutdown_reason(const xc_domaininfo_t *= info) @@ -721,27 +699,6 @@ int xc_domain_getinfo_single(xc_interface *xch, uint32_t domid, xc_domaininfo_t *info); =20 -/** - * This function will return information about one or more domains. It is - * designed to iterate over the list of domains. If a single domain is - * requested, this function will return the next domain in the list - if - * one exists. It is, therefore, important in this case to make sure the - * domain requested was the one returned. - * - * @parm xch a handle to an open hypervisor interface - * @parm first_domid the first domain to enumerate information from. Doma= ins - * are currently enumerate in order of creation. - * @parm max_doms the number of elements in info - * @parm info an array of max_doms size that will contain the information = for - * the enumerated domains. - * @return the number of domains enumerated or -1 on error - */ -int xc_domain_getinfo(xc_interface *xch, - uint32_t first_domid, - unsigned int max_doms, - xc_dominfo_t *info); - - /** * This function will set the execution context for the specified vcpu. * diff --git a/tools/libs/ctrl/xc_domain.c b/tools/libs/ctrl/xc_domain.c index 66179e6f12..724fa6f753 100644 --- a/tools/libs/ctrl/xc_domain.c +++ b/tools/libs/ctrl/xc_domain.c @@ -357,85 +357,12 @@ int xc_domain_getinfo_single(xc_interface *xch, if ( do_domctl(xch, &domctl) < 0 ) return -1; =20 - if ( domctl.u.getdomaininfo.domain !=3D domid ) - { - errno =3D ESRCH; - return -1; - } - if ( info ) *info =3D domctl.u.getdomaininfo; =20 return 0; } =20 -int xc_domain_getinfo(xc_interface *xch, - uint32_t first_domid, - unsigned int max_doms, - xc_dominfo_t *info) -{ - unsigned int nr_doms; - uint32_t next_domid =3D first_domid; - DECLARE_DOMCTL; - int rc =3D 0; - - memset(info, 0, max_doms*sizeof(xc_dominfo_t)); - - for ( nr_doms =3D 0; nr_doms < max_doms; nr_doms++ ) - { - domctl.cmd =3D XEN_DOMCTL_getdomaininfo; - domctl.domain =3D next_domid; - if ( (rc =3D do_domctl(xch, &domctl)) < 0 ) - break; - info->domid =3D domctl.domain; - - info->dying =3D !!(domctl.u.getdomaininfo.flags&XEN_DOMINF_dyin= g); - info->shutdown =3D !!(domctl.u.getdomaininfo.flags&XEN_DOMINF_shut= down); - info->paused =3D !!(domctl.u.getdomaininfo.flags&XEN_DOMINF_paus= ed); - info->blocked =3D !!(domctl.u.getdomaininfo.flags&XEN_DOMINF_bloc= ked); - info->running =3D !!(domctl.u.getdomaininfo.flags&XEN_DOMINF_runn= ing); - info->hvm =3D !!(domctl.u.getdomaininfo.flags&XEN_DOMINF_hvm_= guest); - info->debugged =3D !!(domctl.u.getdomaininfo.flags&XEN_DOMINF_debu= gged); - info->xenstore =3D !!(domctl.u.getdomaininfo.flags&XEN_DOMINF_xs_d= omain); - info->hap =3D !!(domctl.u.getdomaininfo.flags&XEN_DOMINF_hap); - - info->shutdown_reason =3D - (domctl.u.getdomaininfo.flags>>XEN_DOMINF_shutdownshift) & - XEN_DOMINF_shutdownmask; - - if ( info->shutdown && (info->shutdown_reason =3D=3D SHUTDOWN_cras= h) ) - { - info->shutdown =3D 0; - info->crashed =3D 1; - } - - info->ssidref =3D domctl.u.getdomaininfo.ssidref; - info->nr_pages =3D domctl.u.getdomaininfo.tot_pages; - info->nr_outstanding_pages =3D domctl.u.getdomaininfo.outstanding_= pages; - info->nr_shared_pages =3D domctl.u.getdomaininfo.shr_pages; - info->nr_paged_pages =3D domctl.u.getdomaininfo.paged_pages; - info->max_memkb =3D domctl.u.getdomaininfo.max_pages << (PAGE_SHIF= T-10); - info->shared_info_frame =3D domctl.u.getdomaininfo.shared_info_fra= me; - info->cpu_time =3D domctl.u.getdomaininfo.cpu_time; - info->nr_online_vcpus =3D domctl.u.getdomaininfo.nr_online_vcpus; - info->max_vcpu_id =3D domctl.u.getdomaininfo.max_vcpu_id; - info->cpupool =3D domctl.u.getdomaininfo.cpupool; - info->gpaddr_bits =3D domctl.u.getdomaininfo.gpaddr_bits; - info->arch_config =3D domctl.u.getdomaininfo.arch_config; - - memcpy(info->handle, domctl.u.getdomaininfo.handle, - sizeof(xen_domain_handle_t)); - - next_domid =3D (uint16_t)domctl.domain + 1; - info++; - } - - if ( nr_doms =3D=3D 0 ) - return rc; - - return nr_doms; -} - int xc_domain_getinfolist(xc_interface *xch, uint32_t first_domain, unsigned int max_domains, diff --git a/xen/common/domctl.c b/xen/common/domctl.c index ad71ad8a4c..24a14996e6 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -314,7 +314,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) /* fall through */ default: d =3D rcu_lock_domain_by_id(op->domain); - if ( !d && op->cmd !=3D XEN_DOMCTL_getdomaininfo ) + if ( !d ) return -ESRCH; } =20 @@ -534,42 +534,14 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u= _domctl) =20 case XEN_DOMCTL_getdomaininfo: { - domid_t dom =3D DOMID_INVALID; - - if ( !d ) - { - ret =3D -EINVAL; - if ( op->domain >=3D DOMID_FIRST_RESERVED ) - break; - - rcu_read_lock(&domlist_read_lock); - - dom =3D op->domain; - for_each_domain ( d ) - if ( d->domain_id >=3D dom ) - break; - } - - ret =3D -ESRCH; - if ( d =3D=3D NULL ) - goto getdomaininfo_out; - ret =3D xsm_getdomaininfo(XSM_HOOK, d); if ( ret ) - goto getdomaininfo_out; + break; =20 getdomaininfo(d, &op->u.getdomaininfo); =20 op->domain =3D op->u.getdomaininfo.domain; copyback =3D 1; - - getdomaininfo_out: - /* When d was non-NULL upon entry, no cleanup is needed. */ - if ( dom =3D=3D DOMID_INVALID ) - break; - - rcu_read_unlock(&domlist_read_lock); - d =3D NULL; break; } =20 --=20 2.34.1