mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virsh: Fix virshDomainInterfaceSourceCompleter
Introduced in v5.10.0-449-gcf44ec5577 it used virshCommaStringListComplete() to generate list of options. But this is not correct because the '--source' argument of the 'domifaddr' doesn't accept a string list (for instance "arp,agent,lease") rather than a single string. Therefore, the completer must return these strings separately and thus must refrain from using virshCommaStringListComplete(). At the same time, now that we have strings we need declared as an enum we can use TypeToString() instead of copying strings. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
79b9328d76
commit
13fa7b587f
@ -24,6 +24,7 @@
|
|||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "virmacaddr.h"
|
#include "virmacaddr.h"
|
||||||
#include "virsh-domain.h"
|
#include "virsh-domain.h"
|
||||||
|
#include "virsh-domain-monitor.h"
|
||||||
#include "virsh-util.h"
|
#include "virsh-util.h"
|
||||||
#include "virsh.h"
|
#include "virsh.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
@ -299,17 +300,19 @@ virshDomainShutdownModeCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
|
|
||||||
char **
|
char **
|
||||||
virshDomainInterfaceAddrSourceCompleter(vshControl *ctl,
|
virshDomainInterfaceAddrSourceCompleter(vshControl *ctl G_GNUC_UNUSED,
|
||||||
const vshCmd *cmd,
|
const vshCmd *cmd G_GNUC_UNUSED,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
const char *sources[] = {"lease", "agent", "arp", NULL};
|
char **ret = NULL;
|
||||||
const char *source = NULL;
|
size_t i;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
if (vshCommandOptStringQuiet(ctl, cmd, "source", &source) < 0)
|
ret = g_new0(typeof(*ret), VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST + 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return virshCommaStringListComplete(source, sources);
|
for (i = 0; i < VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST; i++)
|
||||||
|
ret[i] = g_strdup(virshDomainInterfaceAddressesSourceTypeToString(i));
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2358,7 +2358,6 @@ static const vshCmdOptDef opts_domifaddr[] = {
|
|||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
VIR_ENUM_DECL(virshDomainInterfaceAddressesSource);
|
|
||||||
VIR_ENUM_IMPL(virshDomainInterfaceAddressesSource,
|
VIR_ENUM_IMPL(virshDomainInterfaceAddressesSource,
|
||||||
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST,
|
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST,
|
||||||
"lease",
|
"lease",
|
||||||
|
@ -26,4 +26,6 @@ char *virshGetDomainDescription(vshControl *ctl, virDomainPtr dom,
|
|||||||
bool title, unsigned int flags)
|
bool title, unsigned int flags)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
VIR_ENUM_DECL(virshDomainInterfaceAddressesSource);
|
||||||
|
|
||||||
extern const vshCmdDef domMonitoringCmds[];
|
extern const vshCmdDef domMonitoringCmds[];
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "virpolkit.h"
|
#include "virpolkit.h"
|
||||||
#include "vsh.h"
|
#include "vsh.h"
|
||||||
#include "virsh-completer.h"
|
#include "virsh-completer.h"
|
||||||
|
#include "virenum.h"
|
||||||
|
|
||||||
#define VIRSH_PROMPT_RW "virsh # "
|
#define VIRSH_PROMPT_RW "virsh # "
|
||||||
#define VIRSH_PROMPT_RO "virsh > "
|
#define VIRSH_PROMPT_RO "virsh > "
|
||||||
|
Loading…
Reference in New Issue
Block a user