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