]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nodedev: refactor CCW state format for use in ccwgroup
authorBoris Fiuczynski <fiuczy@linux.ibm.com>
Tue, 4 Feb 2025 17:11:39 +0000 (18:11 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 5 Feb 2025 16:56:42 +0000 (17:56 +0100)
Refactor to allow reuse in ccwgroup.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/node_device_conf.c

index 433334511fca644935c32b14d3c0877d3457cf18..5024379c4de65bbc2e199c05d1f72d7c01369bbd 100644 (file)
@@ -659,6 +659,18 @@ virNodeDeviceCapCSSDefFormat(virBuffer *buf,
 }
 
 
+static void
+virNodeDeviceCapCCWStateTypeFormat(virBuffer *buf,
+                                   const virNodeDevCCWStateType state_type)
+{
+    if (state_type != VIR_NODE_DEV_CCW_STATE_LAST) {
+        const char *state = virNodeDevCCWStateTypeToString(state_type);
+
+        virBufferEscapeString(buf, "<state>%s</state>\n", state);
+    }
+}
+
+
 char *
 virNodeDeviceDefFormat(const virNodeDeviceDef *def, unsigned int flags)
 {
@@ -746,10 +758,7 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def, unsigned int flags)
             virNodeDeviceCapMdevDefFormat(&buf, data, inactive_state);
             break;
         case VIR_NODE_DEV_CAP_CCW_DEV:
-            if (data->ccw_dev.state != VIR_NODE_DEV_CCW_STATE_LAST) {
-                const char *state = virNodeDevCCWStateTypeToString(data->ccw_dev.state);
-                virBufferEscapeString(&buf, "<state>%s</state>\n", state);
-            }
+            virNodeDeviceCapCCWStateTypeFormat(&buf, data->ccw_dev.state);
             virCCWDeviceAddressFormat(&buf, data->ccw_dev.dev_addr);
             break;
         case VIR_NODE_DEV_CAP_CSS_DEV: