There are more occurrences, but I'm converting --source argument
of domifaddr command only, because I will need it in next commit.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-domain-monitor.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 9e6bc99bf2..de4abbaee7 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -2358,6 +2358,13 @@ static const vshCmdOptDef opts_domifaddr[] = {
{.name = NULL}
};
+VIR_ENUM_DECL(virshDomainInterfaceAddressesSource);
+VIR_ENUM_IMPL(virshDomainInterfaceAddressesSource,
+ VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST,
+ "lease",
+ "agent",
+ "arp");
+
static bool
cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
{
@@ -2379,17 +2386,10 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0)
goto cleanup;
- if (sourcestr) {
- if (STREQ(sourcestr, "lease")) {
- source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE;
- } else if (STREQ(sourcestr, "agent")) {
- source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT;
- } else if (STREQ(sourcestr, "arp")) {
- source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP;
- } else {
- vshError(ctl, _("Unknown data source '%s'"), sourcestr);
- goto cleanup;
- }
+ if (sourcestr &&
+ (source = virshDomainInterfaceAddressesSourceTypeFromString(sourcestr)) < 0)
{
+ vshError(ctl, _("Unknown data source '%s'"), sourcestr);
+ goto cleanup;
}
if ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces, source, 0)) < 0)
{
--
2.24.1