Move virDomainCCWAddressAsString into virccw and rename method as
virCCWDeviceAddressAsString.
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
src/conf/domain_addr.c | 12 +++---------
src/conf/domain_addr.h | 3 ---
src/conf/domain_conf.c | 2 +-
src/libvirt_private.syms | 5 ++++-
src/node_device/node_device_driver.c | 2 +-
src/util/meson.build | 1 +
src/util/virccw.c | 29 ++++++++++++++++++++++++++++
src/util/virccw.h | 3 +++
8 files changed, 42 insertions(+), 15 deletions(-)
create mode 100644 src/util/virccw.c
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index e51056b0a9..7dd26c3271 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1303,12 +1303,6 @@ virDomainPCIAddressSetAllMulti(virDomainDef *def)
}
-char*
-virDomainCCWAddressAsString(virCCWDeviceAddress *addr)
-{
- return g_strdup_printf("%x.%x.%04x", addr->cssid, addr->ssid,
addr->devno);
-}
-
static int
virDomainCCWAddressIncrement(virCCWDeviceAddress *addr)
{
@@ -1334,7 +1328,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
return 0;
if (!autoassign && dev->addr.ccw.assigned) {
- if (!(addr = virDomainCCWAddressAsString(&dev->addr.ccw)))
+ if (!(addr = virCCWDeviceAddressAsString(&dev->addr.ccw)))
return -1;
if (virHashLookup(addrs->defined, addr)) {
@@ -1344,7 +1338,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
return -1;
}
} else if (autoassign && !dev->addr.ccw.assigned) {
- if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
+ if (!(addr = virCCWDeviceAddressAsString(&addrs->next)))
return -1;
while (virHashLookup(addrs->defined, addr)) {
@@ -1354,7 +1348,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
return -1;
}
VIR_FREE(addr);
- if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
+ if (!(addr = virCCWDeviceAddressAsString(&addrs->next)))
return -1;
}
dev->addr.ccw = addrs->next;
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index 8a6e80a84d..e72fb48847 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -209,9 +209,6 @@ int virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
void virDomainCCWAddressSetFree(virDomainCCWAddressSet *addrs);
-char* virDomainCCWAddressAsString(virCCWDeviceAddress *addr)
- ATTRIBUTE_NONNULL(1);
-
virDomainCCWAddressSet *
virDomainCCWAddressSetCreateFromDomain(virDomainDef *def)
ATTRIBUTE_NONNULL(1);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7ef65ebed5..115a670683 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15620,7 +15620,7 @@ virDomainNetFindIdx(virDomainDef *def, virDomainNetDef *net)
alias = net->info.alias;
if (CCWAddrSpecified)
- addr = virDomainCCWAddressAsString(&net->info.addr.ccw);
+ addr = virCCWDeviceAddressAsString(&net->info.addr.ccw);
else if (PCIAddrSpecified)
addr = virPCIDeviceAddressAsString(&net->info.addr.pci);
else
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 97bfca906b..eaf4a1da9c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -147,7 +147,6 @@ virPCIDeviceAddressParseXML;
# conf/domain_addr.h
virDomainCCWAddressAssign;
-virDomainCCWAddressAsString;
virDomainCCWAddressSetCreateFromDomain;
virDomainCCWAddressSetFree;
virDomainPCIAddressBusIsFullyReserved;
@@ -1925,6 +1924,10 @@ virBufferUse;
virBufferVasprintf;
+# util/virccw.h
+virCCWDeviceAddressAsString;
+
+
# util/vircgroup.h
virCgroupAddMachineProcess;
virCgroupAddProcess;
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index b9c46376f5..4b31cd5695 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -667,7 +667,7 @@ nodeDeviceObjFormatAddress(virNodeDeviceObj *obj)
.devno = caps->data.ccw_dev.devno
};
- addr = virDomainCCWAddressAsString(&ccw_addr);
+ addr = virCCWDeviceAddressAsString(&ccw_addr);
break;
}
diff --git a/src/util/meson.build b/src/util/meson.build
index 17755373c8..07ae94631c 100644
--- a/src/util/meson.build
+++ b/src/util/meson.build
@@ -9,6 +9,7 @@ util_sources = [
'virbitmap.c',
'virbpf.c',
'virbuffer.c',
+ 'virccw.c',
'vircgroup.c',
'vircgroupbackend.c',
'vircgroupv1.c',
diff --git a/src/util/virccw.c b/src/util/virccw.c
new file mode 100644
index 0000000000..409287b380
--- /dev/null
+++ b/src/util/virccw.c
@@ -0,0 +1,29 @@
+/*
+ * virccw.c: helper APIs for managing host CCW devices
+ *
+ * Copyright (C) 2022 IBM Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <
http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include "virccw.h"
+
+
+char*
+virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
+{
+ return g_strdup_printf("%x.%x.%04x", addr->cssid, addr->ssid,
addr->devno);
+}
diff --git a/src/util/virccw.h b/src/util/virccw.h
index 701e13284b..21a03406fa 100644
--- a/src/util/virccw.h
+++ b/src/util/virccw.h
@@ -29,3 +29,6 @@ struct _virCCWDeviceAddress {
unsigned int devno;
bool assigned;
};
+
+char* virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
+ ATTRIBUTE_NONNULL(1);
--
2.33.1