3a9410
From 3de657416726803a56fb5b025396bccdd8bfa955 Mon Sep 17 00:00:00 2001
3a9410
Message-Id: <3de657416726803a56fb5b025396bccdd8bfa955@dist-git>
3a9410
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
3a9410
Date: Fri, 13 May 2022 12:31:06 +0200
3a9410
Subject: [PATCH] util: refactor virDomainDeviceCCWAddressIsValid into virccw
3a9410
3a9410
Refactor virDomainDeviceCCWAddressIsValid into virccw and rename method
3a9410
as virCCWDeviceAddressIsValid.
3a9410
3a9410
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
3a9410
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3a9410
(cherry picked from commit 38756ce5ba17d31597a3470d07708a21bf460c9b)
3a9410
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2165011
3a9410
Signed-off-by: Thomas Huth <thuth@redhat.com>
3a9410
---
3a9410
 src/conf/device_conf.c   | 12 ++----------
3a9410
 src/conf/device_conf.h   |  1 -
3a9410
 src/libvirt_private.syms |  2 +-
3a9410
 src/util/virccw.c        |  8 ++++++++
3a9410
 src/util/virccw.h        |  2 ++
3a9410
 5 files changed, 13 insertions(+), 12 deletions(-)
3a9410
3a9410
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
3a9410
index bdc9219f84..2385e81994 100644
3a9410
--- a/src/conf/device_conf.c
3a9410
+++ b/src/conf/device_conf.c
3a9410
@@ -258,14 +258,6 @@ virPCIDeviceAddressFormat(virBuffer *buf,
3a9410
                       addr.function);
3a9410
 }
3a9410
 
3a9410
-bool
3a9410
-virDomainDeviceCCWAddressIsValid(virCCWDeviceAddress *addr)
3a9410
-{
3a9410
-    return addr->cssid <= VIR_CCW_DEVICE_MAX_CSSID &&
3a9410
-           addr->ssid <= VIR_CCW_DEVICE_MAX_SSID &&
3a9410
-           addr->devno <= VIR_CCW_DEVICE_MAX_DEVNO;
3a9410
-}
3a9410
-
3a9410
 int
3a9410
 virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
3a9410
                                   virCCWDeviceAddress *addr)
3a9410
@@ -288,7 +280,7 @@ virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
3a9410
                                 &addr->devno)) < 0)
3a9410
         return -1;
3a9410
 
3a9410
-    if (!virDomainDeviceCCWAddressIsValid(addr)) {
3a9410
+    if (!virCCWDeviceAddressIsValid(addr)) {
3a9410
         virReportError(VIR_ERR_INTERNAL_ERROR,
3a9410
                        _("Invalid specification for virtio ccw address: cssid='0x%x' ssid='0x%x' devno='0x%04x'"),
3a9410
                        addr->cssid, addr->ssid, addr->devno);
3a9410
@@ -453,7 +445,7 @@ virDomainDeviceAddressIsValid(virDomainDeviceInfo *info,
3a9410
         return true;
3a9410
 
3a9410
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW:
3a9410
-        return virDomainDeviceCCWAddressIsValid(&info->addr.ccw);
3a9410
+        return virCCWDeviceAddressIsValid(&info->addr.ccw);
3a9410
 
3a9410
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB:
3a9410
         return true;
3a9410
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
3a9410
index 5c4b7b2f8e..0ed6991c23 100644
3a9410
--- a/src/conf/device_conf.h
3a9410
+++ b/src/conf/device_conf.h
3a9410
@@ -193,7 +193,6 @@ void virPCIDeviceAddressFormat(virBuffer *buf,
3a9410
                                virPCIDeviceAddress addr,
3a9410
                                bool includeTypeInAddr);
3a9410
 
3a9410
-bool virDomainDeviceCCWAddressIsValid(virCCWDeviceAddress *addr);
3a9410
 int virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
3a9410
                                       virCCWDeviceAddress *addr);
3a9410
 bool virDomainDeviceCCWAddressEqual(virCCWDeviceAddress *addr1,
3a9410
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
3a9410
index eb56292b34..9ed367d427 100644
3a9410
--- a/src/libvirt_private.syms
3a9410
+++ b/src/libvirt_private.syms
3a9410
@@ -132,7 +132,6 @@ virDomainDeviceAddressIsValid;
3a9410
 virDomainDeviceAddressTypeToString;
3a9410
 virDomainDeviceCcidAddressParseXML;
3a9410
 virDomainDeviceCCWAddressEqual;
3a9410
-virDomainDeviceCCWAddressIsValid;
3a9410
 virDomainDeviceCCWAddressParseXML;
3a9410
 virDomainDeviceDriveAddressParseXML;
3a9410
 virDomainDeviceInfoAddressIsEqual;
3a9410
@@ -1904,6 +1903,7 @@ virBufferVasprintf;
3a9410
 # util/virccw.h
3a9410
 virCCWDeviceAddressAsString;
3a9410
 virCCWDeviceAddressIncrement;
3a9410
+virCCWDeviceAddressIsValid;
3a9410
 
3a9410
 
3a9410
 # util/vircgroup.h
3a9410
diff --git a/src/util/virccw.c b/src/util/virccw.c
3a9410
index d14d432414..c3dfda2613 100644
3a9410
--- a/src/util/virccw.c
3a9410
+++ b/src/util/virccw.c
3a9410
@@ -22,6 +22,14 @@
3a9410
 #include "virccw.h"
3a9410
 
3a9410
 
3a9410
+bool
3a9410
+virCCWDeviceAddressIsValid(virCCWDeviceAddress *addr)
3a9410
+{
3a9410
+    return addr->cssid <= VIR_CCW_DEVICE_MAX_CSSID &&
3a9410
+           addr->ssid <= VIR_CCW_DEVICE_MAX_SSID &&
3a9410
+           addr->devno <= VIR_CCW_DEVICE_MAX_DEVNO;
3a9410
+}
3a9410
+
3a9410
 char*
3a9410
 virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
3a9410
 {
3a9410
diff --git a/src/util/virccw.h b/src/util/virccw.h
3a9410
index 4c48c9605e..c4daaff7b3 100644
3a9410
--- a/src/util/virccw.h
3a9410
+++ b/src/util/virccw.h
3a9410
@@ -35,6 +35,8 @@ struct _virCCWDeviceAddress {
3a9410
     bool         assigned;
3a9410
 };
3a9410
 
3a9410
+bool virCCWDeviceAddressIsValid(virCCWDeviceAddress *addr);
3a9410
+
3a9410
 char* virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
3a9410
     ATTRIBUTE_NONNULL(1);
3a9410
 int virCCWDeviceAddressIncrement(virCCWDeviceAddress *addr);
3a9410
-- 
3a9410
2.39.1
3a9410