|
|
3a9410 |
From 531244b8147f8972e56b6ba2c7ecf04c072f296a Mon Sep 17 00:00:00 2001
|
|
|
3a9410 |
Message-Id: <531244b8147f8972e56b6ba2c7ecf04c072f296a@dist-git>
|
|
|
3a9410 |
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
3a9410 |
Date: Fri, 13 May 2022 12:31:02 +0200
|
|
|
3a9410 |
Subject: [PATCH] util: refactor virDomainCCWAddressAsString into virccw
|
|
|
3a9410 |
|
|
|
3a9410 |
Move virDomainCCWAddressAsString into virccw and rename method as
|
|
|
3a9410 |
virCCWDeviceAddressAsString.
|
|
|
3a9410 |
|
|
|
3a9410 |
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
3a9410 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
3a9410 |
(cherry picked from commit 1df0a1986978dcb7d1fc139f14adbc4f85b1851f)
|
|
|
3a9410 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2165011
|
|
|
3a9410 |
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
|
3a9410 |
---
|
|
|
3a9410 |
src/conf/domain_addr.c | 12 +++---------
|
|
|
3a9410 |
src/conf/domain_addr.h | 3 ---
|
|
|
3a9410 |
src/conf/domain_conf.c | 2 +-
|
|
|
3a9410 |
src/libvirt_private.syms | 5 ++++-
|
|
|
3a9410 |
src/node_device/node_device_driver.c | 2 +-
|
|
|
3a9410 |
src/util/meson.build | 1 +
|
|
|
3a9410 |
src/util/virccw.c | 29 ++++++++++++++++++++++++++++
|
|
|
3a9410 |
src/util/virccw.h | 3 +++
|
|
|
3a9410 |
8 files changed, 42 insertions(+), 15 deletions(-)
|
|
|
3a9410 |
create mode 100644 src/util/virccw.c
|
|
|
3a9410 |
|
|
|
3a9410 |
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
|
|
|
3a9410 |
index d584d3b8a8..bf51ef5e5a 100644
|
|
|
3a9410 |
--- a/src/conf/domain_addr.c
|
|
|
3a9410 |
+++ b/src/conf/domain_addr.c
|
|
|
3a9410 |
@@ -1286,12 +1286,6 @@ virDomainPCIAddressSetAllMulti(virDomainDef *def)
|
|
|
3a9410 |
}
|
|
|
3a9410 |
|
|
|
3a9410 |
|
|
|
3a9410 |
-char*
|
|
|
3a9410 |
-virDomainCCWAddressAsString(virCCWDeviceAddress *addr)
|
|
|
3a9410 |
-{
|
|
|
3a9410 |
- return g_strdup_printf("%x.%x.%04x", addr->cssid, addr->ssid, addr->devno);
|
|
|
3a9410 |
-}
|
|
|
3a9410 |
-
|
|
|
3a9410 |
static int
|
|
|
3a9410 |
virDomainCCWAddressIncrement(virCCWDeviceAddress *addr)
|
|
|
3a9410 |
{
|
|
|
3a9410 |
@@ -1317,7 +1311,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
|
|
|
3a9410 |
return 0;
|
|
|
3a9410 |
|
|
|
3a9410 |
if (!autoassign && dev->addr.ccw.assigned) {
|
|
|
3a9410 |
- if (!(addr = virDomainCCWAddressAsString(&dev->addr.ccw)))
|
|
|
3a9410 |
+ if (!(addr = virCCWDeviceAddressAsString(&dev->addr.ccw)))
|
|
|
3a9410 |
return -1;
|
|
|
3a9410 |
|
|
|
3a9410 |
if (virHashLookup(addrs->defined, addr)) {
|
|
|
3a9410 |
@@ -1327,7 +1321,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
|
|
|
3a9410 |
return -1;
|
|
|
3a9410 |
}
|
|
|
3a9410 |
} else if (autoassign && !dev->addr.ccw.assigned) {
|
|
|
3a9410 |
- if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
|
|
|
3a9410 |
+ if (!(addr = virCCWDeviceAddressAsString(&addrs->next)))
|
|
|
3a9410 |
return -1;
|
|
|
3a9410 |
|
|
|
3a9410 |
while (virHashLookup(addrs->defined, addr)) {
|
|
|
3a9410 |
@@ -1337,7 +1331,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
|
|
|
3a9410 |
return -1;
|
|
|
3a9410 |
}
|
|
|
3a9410 |
VIR_FREE(addr);
|
|
|
3a9410 |
- if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
|
|
|
3a9410 |
+ if (!(addr = virCCWDeviceAddressAsString(&addrs->next)))
|
|
|
3a9410 |
return -1;
|
|
|
3a9410 |
}
|
|
|
3a9410 |
dev->addr.ccw = addrs->next;
|
|
|
3a9410 |
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
|
|
|
3a9410 |
index c8d069e07e..a67851c327 100644
|
|
|
3a9410 |
--- a/src/conf/domain_addr.h
|
|
|
3a9410 |
+++ b/src/conf/domain_addr.h
|
|
|
3a9410 |
@@ -205,9 +205,6 @@ int virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
|
|
|
3a9410 |
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
3a9410 |
void virDomainCCWAddressSetFree(virDomainCCWAddressSet *addrs);
|
|
|
3a9410 |
|
|
|
3a9410 |
-char* virDomainCCWAddressAsString(virCCWDeviceAddress *addr)
|
|
|
3a9410 |
- ATTRIBUTE_NONNULL(1);
|
|
|
3a9410 |
-
|
|
|
3a9410 |
virDomainCCWAddressSet *
|
|
|
3a9410 |
virDomainCCWAddressSetCreateFromDomain(virDomainDef *def)
|
|
|
3a9410 |
ATTRIBUTE_NONNULL(1);
|
|
|
3a9410 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
3a9410 |
index ad3bd56da0..17383fc878 100644
|
|
|
3a9410 |
--- a/src/conf/domain_conf.c
|
|
|
3a9410 |
+++ b/src/conf/domain_conf.c
|
|
|
3a9410 |
@@ -15793,7 +15793,7 @@ virDomainNetFindIdx(virDomainDef *def, virDomainNetDef *net)
|
|
|
3a9410 |
alias = net->info.alias;
|
|
|
3a9410 |
|
|
|
3a9410 |
if (CCWAddrSpecified)
|
|
|
3a9410 |
- addr = virDomainCCWAddressAsString(&net->info.addr.ccw);
|
|
|
3a9410 |
+ addr = virCCWDeviceAddressAsString(&net->info.addr.ccw);
|
|
|
3a9410 |
else if (PCIAddrSpecified)
|
|
|
3a9410 |
addr = virPCIDeviceAddressAsString(&net->info.addr.pci);
|
|
|
3a9410 |
else
|
|
|
3a9410 |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
3a9410 |
index 568b0f34a1..e8d3edb0fe 100644
|
|
|
3a9410 |
--- a/src/libvirt_private.syms
|
|
|
3a9410 |
+++ b/src/libvirt_private.syms
|
|
|
3a9410 |
@@ -147,7 +147,6 @@ virPCIDeviceAddressParseXML;
|
|
|
3a9410 |
|
|
|
3a9410 |
# conf/domain_addr.h
|
|
|
3a9410 |
virDomainCCWAddressAssign;
|
|
|
3a9410 |
-virDomainCCWAddressAsString;
|
|
|
3a9410 |
virDomainCCWAddressSetCreateFromDomain;
|
|
|
3a9410 |
virDomainCCWAddressSetFree;
|
|
|
3a9410 |
virDomainPCIAddressBusIsFullyReserved;
|
|
|
3a9410 |
@@ -1902,6 +1901,10 @@ virBufferUse;
|
|
|
3a9410 |
virBufferVasprintf;
|
|
|
3a9410 |
|
|
|
3a9410 |
|
|
|
3a9410 |
+# util/virccw.h
|
|
|
3a9410 |
+virCCWDeviceAddressAsString;
|
|
|
3a9410 |
+
|
|
|
3a9410 |
+
|
|
|
3a9410 |
# util/vircgroup.h
|
|
|
3a9410 |
virCgroupAddMachineProcess;
|
|
|
3a9410 |
virCgroupAddProcess;
|
|
|
3a9410 |
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
|
|
|
3a9410 |
index b0abf59618..e6ab4bb94c 100644
|
|
|
3a9410 |
--- a/src/node_device/node_device_driver.c
|
|
|
3a9410 |
+++ b/src/node_device/node_device_driver.c
|
|
|
3a9410 |
@@ -682,7 +682,7 @@ nodeDeviceObjFormatAddress(virNodeDeviceObj *obj)
|
|
|
3a9410 |
.devno = caps->data.ccw_dev.devno
|
|
|
3a9410 |
};
|
|
|
3a9410 |
|
|
|
3a9410 |
- addr = virDomainCCWAddressAsString(&ccw_addr);
|
|
|
3a9410 |
+ addr = virCCWDeviceAddressAsString(&ccw_addr);
|
|
|
3a9410 |
break;
|
|
|
3a9410 |
}
|
|
|
3a9410 |
|
|
|
3a9410 |
diff --git a/src/util/meson.build b/src/util/meson.build
|
|
|
3a9410 |
index 24350a3e67..13ed105798 100644
|
|
|
3a9410 |
--- a/src/util/meson.build
|
|
|
3a9410 |
+++ b/src/util/meson.build
|
|
|
3a9410 |
@@ -9,6 +9,7 @@ util_sources = [
|
|
|
3a9410 |
'virbitmap.c',
|
|
|
3a9410 |
'virbpf.c',
|
|
|
3a9410 |
'virbuffer.c',
|
|
|
3a9410 |
+ 'virccw.c',
|
|
|
3a9410 |
'vircgroup.c',
|
|
|
3a9410 |
'vircgroupbackend.c',
|
|
|
3a9410 |
'vircgroupv1.c',
|
|
|
3a9410 |
diff --git a/src/util/virccw.c b/src/util/virccw.c
|
|
|
3a9410 |
new file mode 100644
|
|
|
3a9410 |
index 0000000000..409287b380
|
|
|
3a9410 |
--- /dev/null
|
|
|
3a9410 |
+++ b/src/util/virccw.c
|
|
|
3a9410 |
@@ -0,0 +1,29 @@
|
|
|
3a9410 |
+/*
|
|
|
3a9410 |
+ * virccw.c: helper APIs for managing host CCW devices
|
|
|
3a9410 |
+ *
|
|
|
3a9410 |
+ * Copyright (C) 2022 IBM Corporation
|
|
|
3a9410 |
+ *
|
|
|
3a9410 |
+ * This library is free software; you can redistribute it and/or
|
|
|
3a9410 |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
3a9410 |
+ * License as published by the Free Software Foundation; either
|
|
|
3a9410 |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
3a9410 |
+ *
|
|
|
3a9410 |
+ * This library is distributed in the hope that it will be useful,
|
|
|
3a9410 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
3a9410 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
3a9410 |
+ * Lesser General Public License for more details.
|
|
|
3a9410 |
+ *
|
|
|
3a9410 |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
3a9410 |
+ * License along with this library. If not, see
|
|
|
3a9410 |
+ * <http://www.gnu.org/licenses/>.
|
|
|
3a9410 |
+ */
|
|
|
3a9410 |
+
|
|
|
3a9410 |
+#include <config.h>
|
|
|
3a9410 |
+#include "virccw.h"
|
|
|
3a9410 |
+
|
|
|
3a9410 |
+
|
|
|
3a9410 |
+char*
|
|
|
3a9410 |
+virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
|
|
|
3a9410 |
+{
|
|
|
3a9410 |
+ return g_strdup_printf("%x.%x.%04x", addr->cssid, addr->ssid, addr->devno);
|
|
|
3a9410 |
+}
|
|
|
3a9410 |
diff --git a/src/util/virccw.h b/src/util/virccw.h
|
|
|
3a9410 |
index 701e13284b..21a03406fa 100644
|
|
|
3a9410 |
--- a/src/util/virccw.h
|
|
|
3a9410 |
+++ b/src/util/virccw.h
|
|
|
3a9410 |
@@ -29,3 +29,6 @@ struct _virCCWDeviceAddress {
|
|
|
3a9410 |
unsigned int devno;
|
|
|
3a9410 |
bool assigned;
|
|
|
3a9410 |
};
|
|
|
3a9410 |
+
|
|
|
3a9410 |
+char* virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
|
|
|
3a9410 |
+ ATTRIBUTE_NONNULL(1);
|
|
|
3a9410 |
--
|
|
|
3a9410 |
2.39.1
|
|
|
3a9410 |
|