From nobody Sat Dec 21 13: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 ARC-Seal: i=1; a=rsa-sha256; t=1707332590; cv=none; d=zohomail.com; s=zohoarc; b=EE8djPeLnLn/sRsnBtE2xSmBiWx2vpHHo7b+J3vluj3VNDbJx9DbsI0aE6cJTjF0tqdiKWucXNAAxt1XgWO7JV1LBQj7F0s90ThsIdmEmGFK7Xm7U8IqA37qb40GbpaD1n5Voek/ZPGALdTKLTD+ZCXUdrKYfJjgGL3Lc5vODLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707332590; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mdaTCdI8ySFmu0E5W0G1WTxxRBPa6Pci0/ksty6Vs5I=; b=DnEpPsF0QhmDtqzRSQVNRaa0pHqwC3dEeMbzjoLJv9h9BzmcfSzyAUJaJYrN55UR+7dUSvJtk3j5k5McK4p2ZZyXlJR1mLNZs3JNpeZKH+Zx7hquxax1xmFKON0llGmyNbC+9/HWiyCIj9cw/POpkVlry2J0kyLKuK3EqM/LuiQ= 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1707332589982921.2185277448821; Wed, 7 Feb 2024 11:03:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.677878.1054776 (Exim 4.92) (envelope-from ) id 1rXnBu-0000te-2n; Wed, 07 Feb 2024 19:02:38 +0000 Received: by outflank-mailman (output) from mailman id 677878.1054776; Wed, 07 Feb 2024 19:02:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rXnBu-0000tX-0H; Wed, 07 Feb 2024 19:02:38 +0000 Received: by outflank-mailman (input) for mailman id 677878; Wed, 07 Feb 2024 19:02:37 +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 1rXnBs-0000tR-Tg for xen-devel@lists.xenproject.org; Wed, 07 Feb 2024 19:02:37 +0000 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [2a00:1450:4864:20::333]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 743332e9-c5eb-11ee-8a4a-1f161083a0e0; Wed, 07 Feb 2024 20:02:35 +0100 (CET) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4101565d20bso7849855e9.2 for ; Wed, 07 Feb 2024 11:02:35 -0800 (PST) Received: from localhost.localdomain (82-64-138-184.subs.proxad.net. [82.64.138.184]) by smtp.googlemail.com with ESMTPSA id h13-20020a05600c314d00b0040fdc7f4fcdsm6226198wmo.4.2024.02.07.11.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 11:02:34 -0800 (PST) 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: 743332e9-c5eb-11ee-8a4a-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rabbit-lu.20230601.gappssmtp.com; s=20230601; t=1707332555; x=1707937355; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mdaTCdI8ySFmu0E5W0G1WTxxRBPa6Pci0/ksty6Vs5I=; b=kgZaPz0LHeePYMcHpUHMZtV83hlGrWjIhf797dI/kS1knPZzBWehfCoeXkRDNQFGnc Ae8r7BgGyDlJ7RgDWtkJdWktd1zzRaOhFjFtK67Z8OpnIC4BW/ZaK0hJQVcWl8lioq2o pzTj4IhTH8jAjkELsUIDgivZYwxkRLhVQxJbnS5EazQ2op9Of+S/5mlYp7WrpQMmvOOA jA8ywzWEal11Qk47vqS4R5zw2Q3GxQvTFPR4eAjFUn6g0pAj7YiZTjHzj+/bGxUscAno sihy/P2pN6NGPaHm2XQa1JVMLFrD7LducrAUeHcEynu/oqxeWx397zHzqICoRM4wK5Sv KlLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707332555; x=1707937355; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mdaTCdI8ySFmu0E5W0G1WTxxRBPa6Pci0/ksty6Vs5I=; b=YD1NIO0ha9PXvLjWTIZTedLGNSuru8bIb/Nmg5LpdJ3eOIOH5PzeL72XafTlMRrksp t6esxSUKHX1HtzLX5Lnr8ddxYnWvHklxgWX3W6lCjs3RBSw+xOhpLLAqGTA4XmzQ6++9 OCZAJ2UP8GJvQuxN+9lcBXcy4OItF50WNk7EKjDczcbGbWZHLSzExb/2O2xi41SY7NGR FGryN0KmwHDHol2H3mgMwZLgHRfUTatnZ7/LbmqqD4clZtATpIwQH6TLbRS9BIKbhBJV hcz71t4ASQ9vETTrePSHyJnu2C03w5YCf0++wZY02Go4jC/u63MiM6ahnXa3F3oyTl2+ CrPw== X-Gm-Message-State: AOJu0YwlZuxFR/d6sTnwf2E2YMGOm2XVXg372fijweCLACXp+2XhZ/Tr 7OaqLTNLus/o6w1rQUrNa8ppYtetpD0hfSlT4dCUaZWgzihCaDQSBlAehf/vTdZUMegxElLahlz rvWI= X-Google-Smtp-Source: AGHT+IF7eD5p5sY0u42jubYJxmZ6uK7J9JFWJ+gQzZsPSpO0aJ8KqByWvwfkeqnif513snA43+OGzg== X-Received: by 2002:a05:600c:310d:b0:40f:d162:944c with SMTP id g13-20020a05600c310d00b0040fd162944cmr5581668wmo.31.1707332554662; Wed, 07 Feb 2024 11:02:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX6E0vfHCynkqxv+VCQGiERZIf7DKowp3PzAkd48ZDkn2wJvD8KNrswi5/SQL8DP3zScyGd80phSmCCjA+4f1EzbQbSC7MfTeF7OZAcObGPsDi87udr From: =?UTF-8?q?zithro=20/=20Cyril=20R=C3=A9bert?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Cyril=20R=C3=A9bert?= , Wei Liu , Anthony PERARD Subject: [PATCH v3] tools/xentop: add option to display dom0 first Date: Wed, 7 Feb 2024 20:02:00 +0100 Message-Id: <92ef4d230e05970e1d685b03125fce44adc55010.1707331801.git.slack@rabbit.lu> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @rabbit-lu.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707332592441100001 From: Cyril R=C3=A9bert Add a command line option to xentop to be able to display dom0 first, on to= p of the list. This is unconditional, so sorting domains with the S option will also ignor= e dom0. Signed-off-by: Cyril R=C3=A9bert (zithro) Reviewed-by: Anthony PERARD --- Changes in v3: (none, just reformatting patch correctly ... hopefully ?!) --- Changes in v2: - bug fix - add documentation --- docs/man/xentop.1.pod | 6 +++++- tools/xentop/xentop.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/docs/man/xentop.1.pod b/docs/man/xentop.1.pod index 126f43d2f3..593a484ce7 100644 --- a/docs/man/xentop.1.pod +++ b/docs/man/xentop.1.pod @@ -5,7 +5,7 @@ xentop - displays real-time information about a Xen system = and domains =3Dhead1 SYNOPSIS =20 B [B<-h>] [B<-V>] [B<-d>SECONDS] [B<-n>] [B<-r>] [B<-v>] [B<-f>] -[B<-b>] [B<-i>ITERATIONS] +[B<-b>] [B<-i>ITERATIONS] [B<-z>] =20 =3Dhead1 DESCRIPTION =20 @@ -57,6 +57,10 @@ output data in batch mode (to stdout) =20 maximum number of iterations xentop should produce before ending =20 +=3Ditem B<-z>, B<--dom0-first> + +display dom0 first, ignoring interactive sorting + =3Dback =20 =3Dhead1 INTERACTIVE COMMANDS diff --git a/tools/xentop/xentop.c b/tools/xentop/xentop.c index 545bd5e96d..0a2fab7f15 100644 --- a/tools/xentop/xentop.c +++ b/tools/xentop/xentop.c @@ -211,6 +211,7 @@ int show_networks =3D 0; int show_vbds =3D 0; int repeat_header =3D 0; int show_full_name =3D 0; +int dom0_first =3D 0; #define PROMPT_VAL_LEN 80 const char *prompt =3D NULL; char prompt_val[PROMPT_VAL_LEN]; @@ -240,6 +241,7 @@ static void usage(const char *program) "-b, --batch output in batch mode, no user input accepted\n" "-i, --iterations number of iterations before exiting\n" "-f, --full-name output the full domain name (not truncated)\= n" + "-z, --dom0-first display dom0 first (ignore sorting)\n" "\n" XENTOP_BUGSTO, program); return; @@ -1163,6 +1165,8 @@ static void top(void) { xenstat_domain **domains; unsigned int i, num_domains =3D 0; + int dom0_index =3D -1; + int sort_start =3D 0, sort_count =3D 0; =20 /* Now get the node information */ if (prev_node !=3D NULL) @@ -1183,11 +1187,27 @@ static void top(void) if(domains =3D=3D NULL) fail("Failed to allocate memory\n"); =20 - for (i=3D0; i < num_domains; i++) + for (i=3D0; i < num_domains; i++) { domains[i] =3D xenstat_node_domain_by_index(cur_node, i); + if ( strcmp(xenstat_domain_name(domains[i]), "Domain-0") =3D=3D 0 ) + dom0_index =3D i; + } + + /* Handle dom0 position, not for dom0-less */ + if ( dom0_first =3D=3D 1 && dom0_index !=3D -1 ){ + /* if dom0 is not first in domains, swap it there */ + if ( dom0_index !=3D 0 ){ + xenstat_domain *tmp; + tmp =3D domains[0]; + domains[0] =3D domains[dom0_index]; + domains[dom0_index] =3D tmp; + } + sort_start =3D 1; + sort_count =3D 1; + } =20 /* Sort */ - qsort(domains, num_domains, sizeof(xenstat_domain *), + qsort((domains+sort_start), (num_domains-sort_count), sizeof(xenstat_doma= in *), (int(*)(const void *, const void *))compare_domains); =20 if(first_domain_index >=3D num_domains) @@ -1242,9 +1262,10 @@ int main(int argc, char **argv) { "batch", no_argument, NULL, 'b' }, { "iterations", required_argument, NULL, 'i' }, { "full-name", no_argument, NULL, 'f' }, + { "dom0-first", no_argument, NULL, 'z' }, { 0, 0, 0, 0 }, }; - const char *sopts =3D "hVnxrvd:bi:f"; + const char *sopts =3D "hVnxrvd:bi:fz"; =20 if (atexit(cleanup) !=3D 0) fail("Failed to install cleanup handler.\n"); @@ -1286,6 +1307,9 @@ int main(int argc, char **argv) case 'f': show_full_name =3D 1; break; + case 'z': + dom0_first =3D 1; + break; } } =20 --=20 2.39.2