From nobody Mon Feb 9 13:57:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1599808156; cv=none; d=zohomail.com; s=zohoarc; b=oBuc2dONEGHBsqyH989MQEGhnYAWFdyuh9Fl9oTVxPFb00o9aa3fztfSXquX1gyq2CCuuo2OxUq8DKxp9A+Fd5jqAl5TXXGNwgs32kvQBghp20Yyzf1riqPS52RpTMYf58QkQMWoFP7vuYPCftGYwQLuQj5YVxyG5uqXqJpr6s0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599808156; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u2yMh5vL7mm7lphv7Oniuhr1d91glYTnyQPEkKIIL68=; b=dayhm/yvcZDSnmd8Fz1XJ7MFGX8ODSBu26va64hWYII3XHnlyTDJkwSOlIKNTPGKxh6avKDUfrTS8Qb6Fsu7bezMTIiCidSyVVegWuq+3NOTQY/jWqtJfDNe3efJGRvzkCan+6perASG8RNNQWSiXxyJhBWN/AeIB+AtZVCg0Wk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1599808156314339.32768378881246; Fri, 11 Sep 2020 00:09:16 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-226-DlSonMMyMu6bQjBaOyky1A-1; Fri, 11 Sep 2020 03:09:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 263D3800470; Fri, 11 Sep 2020 07:09:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01F717512C; Fri, 11 Sep 2020 07:09:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C51B492300; Fri, 11 Sep 2020 07:09:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08B76msT006907 for ; Fri, 11 Sep 2020 03:06:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id F029210F9B4; Fri, 11 Sep 2020 07:06:47 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA7AF10FAA2 for ; Fri, 11 Sep 2020 07:06:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A05A6801225 for ; Fri, 11 Sep 2020 07:06:47 +0000 (UTC) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-68-AAz0GgEpNlaTjhXKTC2EAQ-1; Fri, 11 Sep 2020 03:06:45 -0400 Received: by mail-pj1-f68.google.com with SMTP id kk9so1254513pjb.2 for ; Fri, 11 Sep 2020 00:06:45 -0700 (PDT) Received: from t440p.suse.asia (60-251-47-115.HINET-IP.hinet.net. [60.251.47.115]) by smtp.gmail.com with ESMTPSA id a19sm1252037pfn.10.2020.09.11.00.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 00:06:43 -0700 (PDT) X-MC-Unique: DlSonMMyMu6bQjBaOyky1A-1 X-MC-Unique: AAz0GgEpNlaTjhXKTC2EAQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u2yMh5vL7mm7lphv7Oniuhr1d91glYTnyQPEkKIIL68=; b=WoWkC/adtCOr/bj4xBnqkBd43K0oQm2DyST7HUEPxvp647xRl99HhPx3NfI2QePXqF ORwoJeu07CKiOEjKtE7ZvzXMRKKFVSXZafoV4drhqdzxzyGn/VmF0FWoSUU6138i/JaY AuMc8Ia1hhjUhAXLPypgX7l4QMKrb4gsa8H0Gj6FtdWJ79gkzAOOzlh4txCO8ibA/0+b BZo0Pz/1/UnA3UTqXm7/CwRmT2cJG3YlfzFMf2Qnd3b/NBtUwbFVqY5Kk1xV7GLB4ZuA FXQ4oZ2X7D4Uu4DxnwgqXfLWzgQLYibOzbHbfpGcgzo1jK4nrf9EkOzv1hrf83tVGuG1 W+nw== X-Gm-Message-State: AOAM530uRa+2Psgb8umzRTtfaGgZJoAa78dTANQOHLbbEd7rbZPnFgZT 3tLJx5w+eX0vC1D4lWfSHt17ibX6I2SaJw== X-Google-Smtp-Source: ABdhPJwg9EYzB98X4dy8VgB+RJQB4I4bzZIgtkuyO8EMZTrIcJeRP7upDMBXjHnqBpUKBNxoqcE2pQ== X-Received: by 2002:a17:90a:49c8:: with SMTP id l8mr960663pjm.24.1599808003888; Fri, 11 Sep 2020 00:06:43 -0700 (PDT) From: Lin Ma X-Google-Original-From: Lin Ma To: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/12] virsh: domid: Error out if domain is not active Date: Fri, 11 Sep 2020 15:06:11 +0800 Message-Id: <20200911070619.12325-5-lma@suse.de> In-Reply-To: <20200911070619.12325-1-lma@suse.de> References: <20200911070619.12325-1-lma@suse.de> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Lin Ma X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Lin Ma --- tools/virsh-domain.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d1d3f8e566..86152a53b1 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10458,18 +10458,21 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom; unsigned int id; + bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, VIRSH_BYNAME|VIRSH_BYUUID))) - return false; + return ret; =20 id =3D virDomainGetID(dom); - if (id =3D=3D ((unsigned int)-1)) - vshPrint(ctl, "%s\n", "-"); - else + if (id =3D=3D ((unsigned int)-1)) { + vshError(ctl, "%s", _("Domain is not active")); + } else { vshPrint(ctl, "%d\n", id); + ret =3D true; + } virshDomainFree(dom); - return true; + return ret; } =20 /* --=20 2.26.0