From nobody Sat May 18 21:00:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675072918; cv=none; d=zohomail.com; s=zohoarc; b=NuJcRbJntjCyP1uNjhUjI4sQb6/tEIINw5kmigrfFrwMHrOVlPpO9ygzOSP6Thl2x8CSZpzrQqELv2qDiN0tAZRlX4P3iTO0KSdV9YccqPMCf6G2OiEf8lWuGgkGvkjN2YAyhFuClWh+Kmw0IuBNNb/Hcc1QzOWSdSBIwg4jryo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675072918; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=LvXJ/Kb/3GXrGAPgvFLbSRDnVZYQp6NZG2HevM1kX+4=; b=GCIhg+YES8tnk7eaOdDJGWowT6mv4TbU+Kt7r4Lm5/pCcIqKqH2hp/SN/puhmwcYKwxIjg3Rnut9e0lZWC4QXi1LQteHgb+AuJCUj0zVHQPBYwY5LFK6cstIIUvCG7WRpVf8/kRPfGEblRvur3ZHVDEGtNz7SOoCZHcCW/Jlk1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1675072918751937.7452934482651; Mon, 30 Jan 2023 02:01:58 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-319-CwlvluLyOlCbugCilHMEyw-1; Mon, 30 Jan 2023 05:01:55 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7A2B802D2A; Mon, 30 Jan 2023 10:01:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BEC6C15BAD; Mon, 30 Jan 2023 10:01:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DAA3C1946589; Mon, 30 Jan 2023 10:01:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 03E831946587 for ; Mon, 30 Jan 2023 10:01:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8F1671121318; Mon, 30 Jan 2023 10:01:49 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3710A1121315 for ; Mon, 30 Jan 2023 10:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675072917; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LvXJ/Kb/3GXrGAPgvFLbSRDnVZYQp6NZG2HevM1kX+4=; b=bQe9YcDwokSOetB6Na8qgz/+sNE4+8CSLmdSjjQz6/MVKdhVvp3u2EDcPnTAYeNutNkKhz Ai890NsesVR7Mhf2qAUIwMaKQEPLFHDllCnWgMDcOJMWt53pE8JrOwCRKwMVLAbu69Q5zN pp+XdkKiB+vUwd9mkf6fVJln9dvq2mw= X-MC-Unique: CwlvluLyOlCbugCilHMEyw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virsh: Make domif-setlink work more than once Date: Mon, 30 Jan 2023 11:01:46 +0100 Message-Id: <054b2762e983c6c48252a1ae10fa1c9cccfab333.1675072906.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675072919297100001 Content-Type: text/plain; charset="utf-8"; x-default="true" In virsh, we have this convenient domif-setlink command, which is just a wrapper over virDomainUpdateDeviceFlags() and which allows setting link state of given guest NIC. It does so by fetching corresponding XML snippet and either putting into it, OR if the element already exists setting the attribute to desired value. The XML is then fed into the update API. There's, however, a small bug in detecting the pre-existence of the element and its attribute. The code looks at "link" attribute, while in fact, the attribute is called "state". Resolves: https://gitlab.com/libvirt/libvirt/-/issues/426 Fixes: e575bf082ed4889280be07c986375f1ca15bb7ee Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 6b431bd1e5..59b2b3ce60 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3209,7 +3209,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) } } =20 - if (xmlHasProp(linkNode, BAD_CAST "link")) + if (xmlHasProp(linkNode, BAD_CAST "state")) stateAttr =3D xmlSetProp(linkNode, BAD_CAST "state", BAD_CAST stat= e); else stateAttr =3D xmlNewProp(linkNode, BAD_CAST "state", BAD_CAST stat= e); --=20 2.39.1