1 Star 0 Fork 24

MendeZ/libvirt_anolis

forked from src-anolis-os/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
libvirt-nodedev-refactor-ccw-device-address-parsing-from-XML.patch 4.98 KB
一键复制 编辑 原始数据 按行查看 历史
From ef8c30a091b5b0f08f9405878b49c21c5525dd0a Mon Sep 17 00:00:00 2001
Message-Id: <ef8c30a091b5b0f08f9405878b49c21c5525dd0a@dist-git>
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
Date: Fri, 13 May 2022 12:31:12 +0200
Subject: [PATCH] nodedev: refactor ccw device address parsing from XML
Move ccw device address XML parsing into new method for later reuse.
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 4402295d371a62ab8632d23002283b8a7721e6a7)
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2165011
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
src/conf/node_device_conf.c | 96 ++++++++++++++++++++++---------------
1 file changed, 58 insertions(+), 38 deletions(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 1e00f65717..8982368465 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1141,6 +1141,58 @@ virNodeDevAPMatrixCapabilityParseXML(xmlXPathContextPtr ctxt,
}
+static int
+virNodeDevCCWDeviceAddressParseXML(xmlXPathContextPtr ctxt,
+ xmlNodePtr node,
+ const char *dev_name,
+ virCCWDeviceAddress *ccw_addr)
+{
+ VIR_XPATH_NODE_AUTORESTORE(ctxt)
+ g_autofree char *cssid = NULL;
+ g_autofree char *ssid = NULL;
+ g_autofree char *devno = NULL;
+
+ ctxt->node = node;
+
+ if (!(cssid = virXPathString("string(./cssid[1])", ctxt))) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("missing cssid value for '%s'"), dev_name);
+ return -1;
+ }
+ if (virStrToLong_uip(cssid, NULL, 0, &ccw_addr->cssid) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("invalid cssid value '%s' for '%s'"),
+ cssid, dev_name);
+ return -1;
+ }
+
+ if (!(ssid = virXPathString("string(./ssid[1])", ctxt))) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("missing ssid value for '%s'"), dev_name);
+ return -1;
+ }
+ if (virStrToLong_uip(ssid, NULL, 0, &ccw_addr->ssid) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("invalid ssid value '%s' for '%s'"),
+ ssid, dev_name);
+ return -1;
+ }
+
+ if (!(devno = virXPathString("string(./devno[1])", ctxt))) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("missing devno value for '%s'"), dev_name);
+ return -1;
+ }
+ if (virStrToLong_uip(devno, NULL, 16, &ccw_addr->devno) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("invalid devno value '%s' for '%s'"),
+ devno, dev_name);
+ return -1;
+ }
+
+ return 0;
+}
+
static int
virNodeDevCSSCapabilityParseXML(xmlXPathContextPtr ctxt,
xmlNodePtr node,
@@ -1178,50 +1230,18 @@ virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt,
g_autofree xmlNodePtr *nodes = NULL;
int n = 0;
size_t i = 0;
- g_autofree char *cssid = NULL;
- g_autofree char *ssid = NULL;
- g_autofree char *devno = NULL;
+ g_autofree virCCWDeviceAddress *ccw_addr = NULL;
ctxt->node = node;
- if (!(cssid = virXPathString("string(./cssid[1])", ctxt))) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("missing cssid value for '%s'"), def->name);
- return -1;
- }
-
- if (virStrToLong_uip(cssid, NULL, 0, &ccw_dev->cssid) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("invalid cssid value '%s' for '%s'"),
- cssid, def->name);
- return -1;
- }
-
- if (!(ssid = virXPathString("string(./ssid[1])", ctxt))) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("missing ssid value for '%s'"), def->name);
- return -1;
- }
+ ccw_addr = g_new0(virCCWDeviceAddress, 1);
- if (virStrToLong_uip(ssid, NULL, 0, &ccw_dev->ssid) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("invalid ssid value '%s' for '%s'"),
- ssid, def->name);
+ if (virNodeDevCCWDeviceAddressParseXML(ctxt, node, def->name, ccw_addr) < 0)
return -1;
- }
- if (!(devno = virXPathString("string(./devno[1])", ctxt))) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("missing devno value for '%s'"), def->name);
- return -1;
- }
-
- if (virStrToLong_uip(devno, NULL, 16, &ccw_dev->devno) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("invalid devno value '%s' for '%s'"),
- devno, def->name);
- return -1;
- }
+ ccw_dev->cssid = ccw_addr->cssid;
+ ccw_dev->ssid = ccw_addr->ssid;
+ ccw_dev->devno = ccw_addr->devno;
if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0)
return -1;
--
2.39.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shuaijiakun/libvirt_anolis.git
git@gitee.com:shuaijiakun/libvirt_anolis.git
shuaijiakun
libvirt_anolis
libvirt_anolis
a8.9-virt-stream-an

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385