From nobody Mon Sep 16 19:37:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1705685132068328.60112016156165; Fri, 19 Jan 2024 09:25:32 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id C802D1AEA; Fri, 19 Jan 2024 12:25:30 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A67FD1A4A; Fri, 19 Jan 2024 12:23:59 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4BB47197F; Fri, 19 Jan 2024 12:23:57 -0500 (EST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7A635198C for ; Fri, 19 Jan 2024 12:23:56 -0500 (EST) Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40JGFfAg002774 for ; Fri, 19 Jan 2024 16:39:00 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vqv8dry1n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 19 Jan 2024 16:38:59 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40JGIHUl012089 for ; Fri, 19 Jan 2024 16:38:59 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vqv8dry17-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Jan 2024 16:38:59 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40JECsYe000381; Fri, 19 Jan 2024 16:38:58 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vm4utasjq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Jan 2024 16:38:58 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40JGctOl45089170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Jan 2024 16:38:55 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FC3420040; Fri, 19 Jan 2024 16:38:55 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 52C872004D; Fri, 19 Jan 2024 16:38:55 +0000 (GMT) Received: from fiuczyvm.. (unknown [9.171.151.33]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 19 Jan 2024 16:38:55 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 From: Boris Fiuczynski To: devel@lists.libvirt.org Subject: [PATCH 11/11] virsh: add nodedev-update Date: Fri, 19 Jan 2024 17:38:53 +0100 Message-ID: <20240119163853.10191-12-fiuczy@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240119163853.10191-1-fiuczy@linux.ibm.com> References: <20240119163853.10191-1-fiuczy@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: bwxSTf3LnISNyOkr9wwW0snmkOE8hIjQ X-Proofpoint-ORIG-GUID: z4EeQ-AmUYnLgC4Ogr-T-oSFx3c_78Oa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-19_10,2024-01-19_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 priorityscore=1501 phishscore=0 clxscore=1015 mlxlogscore=604 adultscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401190095 Message-ID-Hash: 3YNVOOMIMS7GEERDG6DXGKTC4BBPMLYW X-Message-ID-Hash: 3YNVOOMIMS7GEERDG6DXGKTC4BBPMLYW X-MailFrom: fiuczy@linux.ibm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: jjongsma@redhat.com, mhartmay@linux.ibm.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1705685132864100001 Add ability to update node devices. Signed-off-by: Boris Fiuczynski --- docs/manpages/virsh.rst | 19 ++++++++ tools/virsh-nodedev.c | 98 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 3315395c54..ec3ad686cb 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5331,6 +5331,25 @@ If *--validate* is specified, validates the format o= f the XML document against an internal RNG schema. =20 =20 +nodedev-update +-------------- + +**Syntax:** + +:: + + nodedev-update device FILE [[--live] [--config] | [--current]] + +Update a device on the host. *device* can be either device name or wwn pair +in "wwnn,wwpn" format (only works for vHBA currently). *file* +contains xml for a top-level description of the node device. +*--current* can be either or both of *live* and *config*, depends on +the hypervisor's implementation. +Both *--live* and *--config* flags may be given, but *--current* is +exclusive. If no flag is specified, behavior is different depending +on hypervisor. + + nodedev-destroy --------------- =20 diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 4acb955efe..279e45c2a0 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -1304,6 +1304,98 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd) } =20 =20 +/* + * "nodedev-update" command + */ +static const vshCmdInfo info_node_device_update[] =3D { + {.name =3D "help", + .data =3D N_("Update a active and/or inactive node device") + }, + {.name =3D "desc", + .data =3D N_("Updates the configuration of a node device") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_node_device_update[] =3D { + {.name =3D "device", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("device name or wwn pair in 'wwnn,wwpn' format"), + .completer =3D virshNodeDeviceNameCompleter, + }, + VIRSH_COMMON_OPT_FILE(N_("file containing an XML description " + "of the device")), + VIRSH_COMMON_OPT_CONFIG(N_("affect next node device startup")), + VIRSH_COMMON_OPT_LIVE(N_("affect running node device")), + VIRSH_COMMON_OPT_CURRENT(N_("affect current state of node device")), + {.name =3D NULL} +}; + +static bool +cmdNodeDeviceUpdate(vshControl *ctl, const vshCmd *cmd) //TODO +{ + bool ret =3D false; + g_autoptr(virshNodeDevice) device =3D NULL; + const char *device_value =3D NULL; + const char *from =3D NULL; + g_autofree char *xml =3D NULL; + bool config =3D vshCommandOptBool(cmd, "config"); + bool live =3D vshCommandOptBool(cmd, "live"); + unsigned int flags =3D VIR_NODE_DEVICE_UPDATE_XML_AFFECT_CURRENT; + + VSH_EXCLUSIVE_OPTIONS("current", "live"); + VSH_EXCLUSIVE_OPTIONS("current", "config"); + + if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0) + return false; + + device =3D vshFindNodeDevice(ctl, device_value); + + if (!device) + return false; + + if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + goto cleanup; + + if (virFileReadAll(from, VSH_MAX_XML_FILE, &xml) < 0) + goto cleanup; + + if (config) + flags |=3D VIR_NETWORK_UPDATE_AFFECT_CONFIG; + if (live) + flags |=3D VIR_NETWORK_UPDATE_AFFECT_LIVE; + + if (virNodeDeviceUpdateXML(device, xml, flags) < 0) { + vshError(ctl, _("Failed to update node device %1$s from '%2$s'"), + virNodeDeviceGetName(device), from); + goto cleanup; + } + + if (config) { + if (live) + vshPrintExtra(ctl, _("Updated node device %1$s persistent conf= ig and live state"), + virNodeDeviceGetName(device)); + else + vshPrintExtra(ctl, _("Updated node device %1$s persistent conf= ig"), + virNodeDeviceGetName(device)); + } else if (live) { + vshPrintExtra(ctl, _("Updated node device %1$s live state"), + virNodeDeviceGetName(device)); + } else if (virNodeDeviceIsActive(device)) { + vshPrintExtra(ctl, _("Updated node device %1$s live state"), + virNodeDeviceGetName(device)); + } else { + vshPrintExtra(ctl, _("Updated node device %1$s persistent config"), + virNodeDeviceGetName(device)); + } + + ret =3D true; + cleanup: + vshReportError(ctl); + return ret; +} + =20 const vshCmdDef nodedevCmds[] =3D { {.name =3D "nodedev-create", @@ -1388,5 +1480,11 @@ const vshCmdDef nodedevCmds[] =3D { .info =3D info_node_device_info, .flags =3D 0 }, + {.name =3D "nodedev-update", + .handler =3D cmdNodeDeviceUpdate, + .opts =3D opts_node_device_update, + .info =3D info_node_device_update, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.42.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org