mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-09-17 21:45:33 +03:00
Compare commits
5 Commits
v4.0.0-rc1
...
v4.0.0-rc2
Author | SHA1 | Date | |
---|---|---|---|
|
75cfb8434e | ||
|
74416b1d48 | ||
|
0d6d5de53e | ||
|
66aa7e02c6 | ||
|
98bc781b42 |
@@ -38,6 +38,19 @@ AC_DEFUN([LIBVIRT_CHECK_READLINE],[
|
||||
LIBS="$lv_saved_libs $extra_LIBS"
|
||||
fi
|
||||
|
||||
AC_CHECK_DECLS([rl_completion_quote_character],
|
||||
[], [],
|
||||
[[#include <stdio.h>
|
||||
#include <readline/readline.h>]])
|
||||
|
||||
if test "$ac_cv_have_decl_rl_completion_quote_character" = "no" ; then
|
||||
if test "$with_readline" = "yes" ; then
|
||||
AC_MSG_ERROR([readline is missing rl_completion_quote_character])
|
||||
else
|
||||
with_readline=no;
|
||||
fi
|
||||
fi
|
||||
|
||||
# The normal library check...
|
||||
LIBVIRT_CHECK_LIB([READLINE], [readline], [readline], [readline/readline.h])
|
||||
|
||||
|
@@ -382,6 +382,12 @@ nodeDeviceNumOfCaps(virNodeDevicePtr device)
|
||||
VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS)
|
||||
ncaps++;
|
||||
}
|
||||
if (caps->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
|
||||
if (caps->data.pci_dev.flags &
|
||||
VIR_NODE_DEV_CAP_FLAG_PCI_MDEV)
|
||||
ncaps++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ret = ncaps;
|
||||
@@ -432,6 +438,15 @@ nodeDeviceListCaps(virNodeDevicePtr device,
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (caps->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
|
||||
if (ncaps < maxnames &&
|
||||
caps->data.pci_dev.flags &
|
||||
VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) {
|
||||
if (VIR_STRDUP(names[ncaps++],
|
||||
virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_MDEV_TYPES)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = ncaps;
|
||||
|
||||
|
@@ -216,6 +216,7 @@ virt_login_shell_CFLAGS = \
|
||||
|
||||
virsh_SOURCES = \
|
||||
virsh.c virsh.h \
|
||||
virsh-completer.c virsh-completer.h \
|
||||
virsh-console.c virsh-console.h \
|
||||
virsh-domain.c virsh-domain.h \
|
||||
virsh-domain-monitor.c virsh-domain-monitor.h \
|
||||
@@ -231,15 +232,6 @@ virsh_SOURCES = \
|
||||
virsh-volume.c virsh-volume.h \
|
||||
$(NULL)
|
||||
|
||||
VIRSH_COMPLETER = \
|
||||
virsh-completer.c virsh-completer.h
|
||||
|
||||
if WITH_READLINE
|
||||
virsh_SOURCES += $(VIRSH_COMPLETER)
|
||||
else ! WITH_READLINE
|
||||
EXTRA_DIST += $(VIRSH_COMPLETER)
|
||||
endif ! WITH_READLINE
|
||||
|
||||
virsh_LDFLAGS = \
|
||||
$(AM_LDFLAGS) \
|
||||
$(PIE_LDFLAGS) \
|
||||
@@ -256,17 +248,9 @@ virsh_CFLAGS = \
|
||||
|
||||
virt_admin_SOURCES = \
|
||||
virt-admin.c virt-admin.h \
|
||||
virt-admin-completer.c virt-admin-completer.h \
|
||||
$(NULL)
|
||||
|
||||
VIRT_ADMIN_COMPLETER = \
|
||||
virt-admin-completer.c virt-admin-completer.h
|
||||
|
||||
if WITH_READLINE
|
||||
virt_admin_SOURCES += $(VIRT_ADMIN_COMPLETER)
|
||||
else ! WITH_READLINE
|
||||
EXTRA_DIST += $(VIRT_ADMIN_COMPLETER)
|
||||
endif ! WITH_READLINE
|
||||
|
||||
virt_admin_LDFLAGS = \
|
||||
$(AM_LDFLAGS) \
|
||||
$(COVERAGE_LDFLAGS) \
|
||||
|
96
tools/vsh.c
96
tools/vsh.c
@@ -2663,7 +2663,9 @@ vshReadlineCommandGenerator(const char *text)
|
||||
}
|
||||
|
||||
static char **
|
||||
vshReadlineOptionsGenerator(const char *text, const vshCmdDef *cmd)
|
||||
vshReadlineOptionsGenerator(const char *text,
|
||||
const vshCmdDef *cmd,
|
||||
vshCmd *last)
|
||||
{
|
||||
size_t list_index = 0;
|
||||
size_t len = strlen(text);
|
||||
@@ -2678,6 +2680,8 @@ vshReadlineOptionsGenerator(const char *text, const vshCmdDef *cmd)
|
||||
return NULL;
|
||||
|
||||
while ((name = cmd->opts[list_index].name)) {
|
||||
bool exists = false;
|
||||
vshCmdOpt *opt = last->opts;
|
||||
size_t name_len;
|
||||
|
||||
list_index++;
|
||||
@@ -2692,6 +2696,18 @@ vshReadlineOptionsGenerator(const char *text, const vshCmdDef *cmd)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (opt) {
|
||||
if (STREQ(opt->def->name, name)) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
|
||||
opt = opt->next;
|
||||
}
|
||||
|
||||
if (exists)
|
||||
continue;
|
||||
|
||||
if (VIR_REALLOC_N(ret, ret_size + 2) < 0) {
|
||||
virStringListFree(ret);
|
||||
return NULL;
|
||||
@@ -2772,60 +2788,6 @@ vshCompleterFilter(char ***list,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
vshReadlineOptionsPrune(char ***list,
|
||||
vshCmd *last)
|
||||
{
|
||||
char **newList = NULL;
|
||||
size_t newList_len = 0;
|
||||
size_t list_len;
|
||||
size_t i;
|
||||
|
||||
if (!list || !*list)
|
||||
return -1;
|
||||
|
||||
if (!last->opts)
|
||||
return 0;
|
||||
|
||||
list_len = virStringListLength((const char **) *list);
|
||||
|
||||
if (VIR_ALLOC_N(newList, list_len + 1) < 0)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < list_len; i++) {
|
||||
const char *list_opt = STRSKIP((*list)[i], "--");
|
||||
bool exist = false;
|
||||
vshCmdOpt *opt = last->opts;
|
||||
|
||||
/* Should never happen (TM) */
|
||||
if (!list_opt)
|
||||
return -1;
|
||||
|
||||
while (opt) {
|
||||
if (STREQ(opt->def->name, list_opt)) {
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
|
||||
opt = opt->next;
|
||||
}
|
||||
|
||||
if (exist) {
|
||||
VIR_FREE((*list)[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
VIR_STEAL_PTR(newList[newList_len], (*list)[i]);
|
||||
newList_len++;
|
||||
}
|
||||
|
||||
ignore_value(VIR_REALLOC_N_QUIET(newList, newList_len + 1));
|
||||
VIR_FREE(*list);
|
||||
*list = newList;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
vshReadlineParse(const char *text, int state)
|
||||
{
|
||||
@@ -2874,12 +2836,8 @@ vshReadlineParse(const char *text, int state)
|
||||
if (!cmd) {
|
||||
list = vshReadlineCommandGenerator(text);
|
||||
} else {
|
||||
if (!opt || (opt->type != VSH_OT_DATA && opt->type != VSH_OT_STRING)) {
|
||||
list = vshReadlineOptionsGenerator(text, cmd);
|
||||
|
||||
if (vshReadlineOptionsPrune(&list, partial) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
if (!opt || (opt->type != VSH_OT_DATA && opt->type != VSH_OT_STRING))
|
||||
list = vshReadlineOptionsGenerator(text, cmd, partial);
|
||||
|
||||
if (opt && opt->completer) {
|
||||
char **completer_list = opt->completer(autoCompleteOpaque,
|
||||
@@ -3499,11 +3457,12 @@ const vshCmdInfo info_complete[] = {
|
||||
{.name = NULL}
|
||||
};
|
||||
|
||||
|
||||
#ifdef WITH_READLINE
|
||||
bool
|
||||
cmdComplete(vshControl *ctl, const vshCmd *cmd)
|
||||
{
|
||||
bool ret = false;
|
||||
#ifdef WITH_READLINE
|
||||
const vshClientHooks *hooks = ctl->hooks;
|
||||
int stdin_fileno = STDIN_FILENO;
|
||||
const char *arg = "";
|
||||
@@ -3552,6 +3511,17 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd)
|
||||
cleanup:
|
||||
virBufferFreeAndReset(&buf);
|
||||
virStringListFree(matches);
|
||||
#endif /* WITH_READLINE */
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#else /* !WITH_READLINE */
|
||||
|
||||
|
||||
bool
|
||||
cmdComplete(vshControl *ctl ATTRIBUTE_UNUSED,
|
||||
const vshCmd *cmd ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif /* !WITH_READLINE */
|
||||
|
Reference in New Issue
Block a user