mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
util: add virCCWDeviceAddressFromString to virccw
Add a method to parse a ccw device address from a string. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
8d52f99f0b
commit
9453eb458a
@ -248,6 +248,7 @@ src/util/virauth.c
|
||||
src/util/virauthconfig.c
|
||||
src/util/virbitmap.c
|
||||
src/util/vircgroup.c
|
||||
src/util/virccw.c
|
||||
src/util/vircgroupbackend.c
|
||||
src/util/vircgroupbackend.h
|
||||
src/util/vircgroupv1.c
|
||||
|
@ -1926,6 +1926,7 @@ virBufferVasprintf;
|
||||
# util/virccw.h
|
||||
virCCWDeviceAddressAsString;
|
||||
virCCWDeviceAddressEqual;
|
||||
virCCWDeviceAddressFromString;
|
||||
virCCWDeviceAddressIncrement;
|
||||
virCCWDeviceAddressIsValid;
|
||||
virCCWDeviceAddressParseFromString;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user