[PATCH 11/17] util: add virCCWDeviceAddressFromString to virccw

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a method to parse a ccw device address from a string.

Signed-off-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
---
 po/POTFILES.in           |  1 +
 src/libvirt_private.syms |  1 +
 src/util/virccw.c        | 23 +++++++++++++++++++++++
 src/util/virccw.h        |  3 +++
 4 files changed, 28 insertions(+)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0d9adb0758..71d113efa2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -247,6 +247,7 @@
 @SRCDIR@src/util/virauth.c
 @SRCDIR@src/util/virauthconfig.c
 @SRCDIR@src/util/virbitmap.c
+@SRCDIR@src/util/virccw.c
 @SRCDIR@src/util/vircgroup.c
 @SRCDIR@src/util/vircgroupbackend.c
 @SRCDIR@src/util/vircgroupbackend.h
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 148d016e0e..7c37763bd7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1925,6 +1925,7 @@ virBufferVasprintf;
 # util/virccw.h
 virCCWDeviceAddressAsString;
 virCCWDeviceAddressEqual;
+virCCWDeviceAddressFromString;
 virCCWDeviceAddressIncrement;
 virCCWDeviceAddressIsValid;
 virCCWDeviceAddressParseFromString;
diff --git a/src/util/virccw.c b/src/util/virccw.c
index 33df1c2428..d741743050 100644
--- a/src/util/virccw.c
+++ b/src/util/virccw.c
@@ -20,8 +20,11 @@
 
 #include <config.h>
 #include "virccw.h"
+#include "virerror.h"
 #include "virstring.h"
 
+#define VIR_FROM_THIS VIR_FROM_NONE
+
 
 bool
 virCCWDeviceAddressIsValid(virCCWDeviceAddress *addr)
@@ -49,6 +52,26 @@ virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
     return g_strdup_printf(VIR_CCW_DEVICE_ADDRESS_FMT, addr->cssid, addr->ssid, addr->devno);
 }
 
+virCCWDeviceAddress *
+virCCWDeviceAddressFromString(const char *address)
+{
+    g_autofree virCCWDeviceAddress *ccw = NULL;
+
+    ccw = g_new0(virCCWDeviceAddress, 1);
+
+    if (virCCWDeviceAddressParseFromString(address,
+                                           &ccw->cssid,
+                                           &ccw->ssid,
+                                           &ccw->devno) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Failed to parse CCW address '%s'"),
+                       address);
+        return NULL;
+    }
+
+    return g_steal_pointer(&ccw);
+}
+
 int
 virCCWDeviceAddressIncrement(virCCWDeviceAddress *addr)
 {
diff --git a/src/util/virccw.h b/src/util/virccw.h
index df0273bcac..80cc716811 100644
--- a/src/util/virccw.h
+++ b/src/util/virccw.h
@@ -41,6 +41,9 @@ bool virCCWDeviceAddressEqual(virCCWDeviceAddress *addr1,
 
 char* virCCWDeviceAddressAsString(virCCWDeviceAddress *addr)
     ATTRIBUTE_NONNULL(1);
+virCCWDeviceAddress *virCCWDeviceAddressFromString(const char *address)
+    ATTRIBUTE_NONNULL(1);
+
 int virCCWDeviceAddressIncrement(virCCWDeviceAddress *addr);
 
 int virCCWDeviceAddressParseFromString(const char *address,
-- 
2.33.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux