mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virsh: Use VIR_ENUM_* instead of open coding string -> enum conversion
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@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
207d38f7a2
commit
79b9328d76
@ -2358,6 +2358,13 @@ static const vshCmdOptDef opts_domifaddr[] = {
|
|||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VIR_ENUM_DECL(virshDomainInterfaceAddressesSource);
|
||||||
|
VIR_ENUM_IMPL(virshDomainInterfaceAddressesSource,
|
||||||
|
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST,
|
||||||
|
"lease",
|
||||||
|
"agent",
|
||||||
|
"arp");
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
|
cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
@ -2379,17 +2386,10 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (sourcestr) {
|
if (sourcestr &&
|
||||||
if (STREQ(sourcestr, "lease")) {
|
(source = virshDomainInterfaceAddressesSourceTypeFromString(sourcestr)) < 0) {
|
||||||
source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE;
|
vshError(ctl, _("Unknown data source '%s'"), sourcestr);
|
||||||
} else if (STREQ(sourcestr, "agent")) {
|
goto cleanup;
|
||||||
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 ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces, source, 0)) < 0) {
|
if ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces, source, 0)) < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user