render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
2cf05b
From fcb45d357cc3b6e9ee413014e21de1ab2d20273f Mon Sep 17 00:00:00 2001
2cf05b
Message-Id: <fcb45d357cc3b6e9ee413014e21de1ab2d20273f@dist-git>
2cf05b
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
2cf05b
Date: Fri, 13 May 2022 12:31:05 +0200
2cf05b
Subject: [PATCH] util: refactor virDomainCCWAddressIncrement into virccw
2cf05b
2cf05b
Refactor virDomainCCWAddressIncrement into virccw and rename method as
2cf05b
virCCWDeviceAddressIncrement.
2cf05b
2cf05b
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2cf05b
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2cf05b
(cherry picked from commit be1e16ed1161173b07f2e8f20f2ca3294ac49406)
2cf05b
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2165011
2cf05b
Signed-off-by: Thomas Huth <thuth@redhat.com>
2cf05b
---
2cf05b
 src/conf/domain_addr.c   | 16 +---------------
2cf05b
 src/libvirt_private.syms |  1 +
2cf05b
 src/util/virccw.c        | 13 +++++++++++++
2cf05b
 src/util/virccw.h        |  1 +
2cf05b
 4 files changed, 16 insertions(+), 15 deletions(-)
2cf05b
2cf05b
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
2cf05b
index 655f3cc09e..b04ab0628b 100644
2cf05b
--- a/src/conf/domain_addr.c
2cf05b
+++ b/src/conf/domain_addr.c
2cf05b
@@ -1286,20 +1286,6 @@ virDomainPCIAddressSetAllMulti(virDomainDef *def)
2cf05b
 }
2cf05b
 
2cf05b
 
2cf05b
-static int
2cf05b
-virDomainCCWAddressIncrement(virCCWDeviceAddress *addr)
2cf05b
-{
2cf05b
-    virCCWDeviceAddress ccwaddr = *addr;
2cf05b
-
2cf05b
-    /* We are not touching subchannel sets and channel subsystems */
2cf05b
-    if (++ccwaddr.devno > VIR_CCW_DEVICE_MAX_DEVNO)
2cf05b
-        return -1;
2cf05b
-
2cf05b
-    *addr = ccwaddr;
2cf05b
-    return 0;
2cf05b
-}
2cf05b
-
2cf05b
-
2cf05b
 int
2cf05b
 virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
2cf05b
                           virDomainCCWAddressSet *addrs,
2cf05b
@@ -1325,7 +1311,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
2cf05b
             return -1;
2cf05b
 
2cf05b
         while (virHashLookup(addrs->defined, addr)) {
2cf05b
-            if (virDomainCCWAddressIncrement(&addrs->next) < 0) {
2cf05b
+            if (virCCWDeviceAddressIncrement(&addrs->next) < 0) {
2cf05b
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
2cf05b
                                _("There are no more free CCW devnos."));
2cf05b
                 return -1;
2cf05b
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
2cf05b
index e8d3edb0fe..eb56292b34 100644
2cf05b
--- a/src/libvirt_private.syms
2cf05b
+++ b/src/libvirt_private.syms
2cf05b
@@ -1903,6 +1903,7 @@ virBufferVasprintf;
2cf05b
 
2cf05b
 # util/virccw.h
2cf05b
 virCCWDeviceAddressAsString;
2cf05b
+virCCWDeviceAddressIncrement;
2cf05b
 
2cf05b
 
2cf05b
 # util/vircgroup.h
2cf05b
diff --git a/src/util/virccw.c b/src/util/virccw.c
2cf05b
index 5a19d3a112..d14d432414 100644
2cf05b
--- a/src/util/virccw.c
2cf05b
+++ b/src/util/virccw.c
2cf05b
@@ -27,3 +27,16 @@ virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
2cf05b
 {
2cf05b
     return g_strdup_printf(VIR_CCW_DEVICE_ADDRESS_FMT, addr->cssid, addr->ssid, addr->devno);
2cf05b
 }
2cf05b
+
2cf05b
+int
2cf05b
+virCCWDeviceAddressIncrement(virCCWDeviceAddress *addr)
2cf05b
+{
2cf05b
+    virCCWDeviceAddress ccwaddr = *addr;
2cf05b
+
2cf05b
+    /* We are not touching subchannel sets and channel subsystems */
2cf05b
+    if (++ccwaddr.devno > VIR_CCW_DEVICE_MAX_DEVNO)
2cf05b
+        return -1;
2cf05b
+
2cf05b
+    *addr = ccwaddr;
2cf05b
+    return 0;
2cf05b
+}
2cf05b
diff --git a/src/util/virccw.h b/src/util/virccw.h
2cf05b
index c3a47127f1..4c48c9605e 100644
2cf05b
--- a/src/util/virccw.h
2cf05b
+++ b/src/util/virccw.h
2cf05b
@@ -37,3 +37,4 @@ struct _virCCWDeviceAddress {
2cf05b
 
2cf05b
 char* virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
2cf05b
     ATTRIBUTE_NONNULL(1);
2cf05b
+int virCCWDeviceAddressIncrement(virCCWDeviceAddress *addr);
2cf05b
-- 
2cf05b
2.39.1
2cf05b