[libvirt] [PATCH 0/3] Couple of build fixes for readline stuff
by Michal Privoznik
After I've merged bash completion patches, couple of build problems
emerged.
Michal Privoznik (3):
vsh: Mark cmdComplete arguments as unused
tools: Always compile {virsh,virt-admin}-completer.c
m4: Check for rl_completion_quote_character
m4/virt-readline.m4 | 13 +++++++++++++
tools/Makefile.am | 20 ++------------------
tools/vsh.c | 3 ++-
3 files changed, 17 insertions(+), 19 deletions(-)
--
2.13.6
6 years, 11 months
[libvirt] [PATCH] check/add for mdev_types capability
by Dan Zheng
>From be62ea5394d52fa168079edc3aa7e558363a3026 Mon Sep 17 00:00:00 2001
From: Dan Zheng <dzheng(a)redhat.com>
Date: Tue, 16 Jan 2018 12:21:21 +0800
Subject: [PATCH] nodedev: check/add for mdev_types capability
This is similar to commit f44ec9c1.
Commit id '500cbc06' introduced a new nested capability element of type
'mdev_types' and the ability to use the flag as a way to search for a
specific subset of a 'pci' device - namely a 'mdev_types'.
The code modified the virNodeDeviceCapMatch whichs allows for
searching using the 'virsh nodedev-list [cap]' via
virConnectListAllNodeDevices.
However, the original patches did not account for other searches for
the same capability key from virNodeDeviceNumOfCaps and
virNodeDeviceListCaps using nodeDeviceNumOfCaps and nodeDeviceListCaps.
This patch adds the check for the 'mdev_types' bits within a 'pci'
device and allows the following python code to find the capabilities
for the device:
import libvirt
conn = libvirt.openReadOnly('qemu:///system')
devs = conn.listAllDevices()
for dev in devs:
if 'mdev_types' in dev.listCaps():
print dev.name(),dev.numOfCaps(),dev.listCaps()
Signed-off-by: Dan Zheng <dzheng(a)redhat.com>
---
src/node_device/node_device_driver.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index facfeb6..6216a69 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -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;
--
1.8.3.1
--
Best Regards,
Dan Zheng(郑丹)
Red Hat Software (Beijing) Co.
9/F, North Tower C, Raycom Infotech Park
No.2 Ke Xueyuan Nanlu, Haidian District Beijing 100190
6 years, 11 months
[libvirt] [libvirt-tck] [PATCH] Add new option for virt-builder
by Dan Zheng
>From 0cbe381e782a18cfa9730e8791a80ff01497d8fc Mon Sep 17 00:00:00 2001
From: Dan Zheng <dzheng(a)redhat.com>
Date: Tue, 16 Jan 2018 13:39:50 +0800
Subject: [PATCH] Add new option for virt-builder
Using --selinux-relabel is required by Fedora and RHEL guests to ensure
SELinux labels correctly in the disk image.
Signed-off-by: Dan Zheng <dzheng(a)redhat.com>
---
lib/Sys/Virt/TCK.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
index e9da8d2..1621342 100644
--- a/lib/Sys/Virt/TCK.pm
+++ b/lib/Sys/Virt/TCK.pm
@@ -405,7 +405,7 @@ sub create_virt_builder_disk {
}
print "# running virt-builder $osname\n";
- system "virt-builder", "--install", "dsniff", "--root-password", "password:$password", "--output", $target, $osname;
+ system "virt-builder", "--install", "dsniff", "--root-password", "password:$password", "--output", $target, $osname, "--selinux-relabel";
die "cannot run virt-builder: $?" if $? != 0;
--
1.8.3.1
--
Best Regards,
Dan Zheng(郑丹)
Red Hat Software (Beijing) Co.
9/F, North Tower C, Raycom Infotech Park
No.2 Ke Xueyuan Nanlu, Haidian District Beijing 100190
6 years, 11 months
[libvirt] [PATCH perl] block_stats: Fix rd_req and wr_req compat hash keys
by Ville Skyttä
When virDomainBlockStatsFlags with NULL params fails, the returned
read and write requests hash keys are said to be backwards compatible
with the key names success case. However, they were rd_reqs and
wr_reqs (in plural) as opposed to the success case's rd_req and
wr_req.
There is also a similar flush_reqs key, but that one does not have a
corresponding value in the success case's hash, so it is left
unmodified here.
---
Virt.xs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Virt.xs b/Virt.xs
index c47b915..a6f0477 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -5611,9 +5611,9 @@ block_stats(dom, path, flags=0)
field = NULL;
/* For back compat with previous hash above */
if (strcmp(params[i].field, "rd_operations") == 0)
- field = "rd_reqs";
+ field = "rd_req";
else if (strcmp(params[i].field, "wr_operations") == 0)
- field = "wr_reqs";
+ field = "wr_req";
else if (strcmp(params[i].field, "flush_operations") == 0)
field = "flush_reqs";
if (field) {
--
2.14.1
6 years, 11 months
[libvirt] [PATCH perl] Spelling fixes
by Ville Skyttä
---
Changes | 4 ++--
HACKING | 4 ++--
lib/Sys/Virt.pm | 6 +++---
lib/Sys/Virt/Domain.pm | 14 +++++++-------
lib/Sys/Virt/Interface.pm | 2 +-
lib/Sys/Virt/NWFilter.pm | 2 +-
lib/Sys/Virt/Network.pm | 4 ++--
lib/Sys/Virt/NodeDevice.pm | 4 ++--
lib/Sys/Virt/Secret.pm | 4 ++--
lib/Sys/Virt/StoragePool.pm | 4 ++--
lib/Sys/Virt/StorageVol.pm | 8 ++++----
lib/Sys/Virt/Stream.pm | 2 +-
12 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/Changes b/Changes
index 96b42f8..0571cf8 100644
--- a/Changes
+++ b/Changes
@@ -472,7 +472,7 @@ Revision history for perl module Sys::Virt
0.2.6 2011-02-16
- Fix build with 0.8.7 libvirt by removing reference to
- non-existant constant only introduced in libvirt > 0.8.7
+ non-existent constant only introduced in libvirt > 0.8.7
- Fix test script when hostname is undefined
0.2.5 2011-02-04
@@ -533,7 +533,7 @@ Revision history for perl module Sys::Virt
- Added networking APIs
- Added APIs for host capabilities
- Added APIs for inactive domains
- - Switch licensse to GPLv2+ or Artistic for CPAN compatability
+ - Switch licensse to GPLv2+ or Artistic for CPAN compatibility
- Fix return values for reboot/shutdown/undefine/create APIs
- Expanded documentation coverage
diff --git a/HACKING b/HACKING
index bb8b0f0..bfd1212 100644
--- a/HACKING
+++ b/HACKING
@@ -15,7 +15,7 @@ Additions to the libvirt C API will require changes to a minimum
of two parts of the Sys::Virt codebase.
- Virt.xs - this provides the C glue code to access the libvirt C
- library APIs and constants from the Perl interpretor. As a general
+ library APIs and constants from the Perl interpreter. As a general
rule, every new function and header file constant/enum requires an
addition to this file. The exceptions are functions that are only
provided for the benefit of language bindings and not intended for
@@ -93,7 +93,7 @@ effective way to update the Perl binding.
- For each missing item reported in the test suite...
- Edit Virt.xs to add the C binding
- - Edit lib/*.pm to add the POD documentation (and occassionally Perl glue code)
+ - Edit lib/*.pm to add the POD documentation (and occasionally Perl glue code)
- Edit Changes to document the addition
- Run the test suite (without maintainer mode) to verify POD docs
# ../libvirt/run make test
diff --git a/lib/Sys/Virt.pm b/lib/Sys/Virt.pm
index 2ce7ed5..faaf668 100644
--- a/lib/Sys/Virt.pm
+++ b/lib/Sys/Virt.pm
@@ -135,7 +135,7 @@ types that will be supported. The credential constants in
this module can be used as values in this list. The C<callback>
parameter should be a subroutine reference containing the
code necessary to gather the credentials. When invoked it
-will be supplied with a single parameter, a array reference
+will be supplied with a single parameter, an array reference
of requested credentials. The elements of the array are
hash references, with keys C<type> giving the type of
credential, C<prompt> giving a user descriptive user
@@ -1164,7 +1164,7 @@ pool sources.
=item my @stats = $vmm->get_all_domain_stats($stats, \@doms=undef, $flags=0);
-Get an list of all statistics for domains known to the hypervisor.
+Get a list of all statistics for domains known to the hypervisor.
The C<$stats> parameter controls which data fields to return and
should be a combination of the DOMAIN STATS FIELD CONSTANTS.
@@ -1469,7 +1469,7 @@ how long the node is suspended for before waking up.
=item $conn->domain_event_register($callback)
-Register a callback to received notificaitons of domain state change
+Register a callback to received notifications of domain state change
events. Only a single callback can be registered with each connection
instance. The callback will be invoked with four parameters, an
instance of C<Sys::Virt> for the connection, an instance of C<Sys::Virt::Domain>
diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm
index 38b9c9b..7b90b68 100644
--- a/lib/Sys/Virt/Domain.pm
+++ b/lib/Sys/Virt/Domain.pm
@@ -45,7 +45,7 @@ sub _new {
my $class = ref($proto) || $proto;
my %params = @_;
- my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried";
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
my $self;
if (exists $params{name}) {
$self = Sys::Virt::Domain::_lookup_by_name($con, $params{name});
@@ -490,7 +490,7 @@ One of the CONTROL INFO constants listed later
=item C<details>
-Currently unsed, always 0.
+Currently unused, always 0.
=item C<stateTime>
@@ -658,7 +658,7 @@ later.
=item $dom->detach_device($xml[, $flags])
-Hotunplug a existing device whose configuration is given by C<$xml>,
+Hotunplug an existing device whose configuration is given by C<$xml>,
from the running guest. The optional <$flags> parameter defaults
to 0, but can accept one of the device hotplug flags described
later.
@@ -1719,7 +1719,7 @@ instead of MB/s.
Abort the current job that is executing for the block device
associated with C<$path>
-=item $dom->block_pull($path, $bandwith, $flags=0)
+=item $dom->block_pull($path, $bandwidth, $flags=0)
Merge the backing files associated with C<$path> into the
top level file. The C<$bandwidth> parameter specifies the
@@ -1735,7 +1735,7 @@ instead of MB/s.
=back
-=item $dom->block_rebase($path, $base, $bandwith, $flags=0)
+=item $dom->block_rebase($path, $base, $bandwidth, $flags=0)
Switch the backing path associated with C<$path> to instead
use C<$base>. The C<$bandwidth> parameter specifies the
@@ -1774,7 +1774,7 @@ The maximum amount of data in flight in bytes.
=back
-=item $dom->block_commit($path, $base, $top, $bandwith, $flags=0)
+=item $dom->block_commit($path, $base, $top, $bandwidth, $flags=0)
Commit changes there were made to the temporary top level file C<$top>.
Takes all the differences between C<$top> and C<$base> and merge them
@@ -3827,7 +3827,7 @@ The host storage has run out of free space
=item Sys::Virt::Domain::DISK_ERROR_UNSPEC
-An unspecified error has ocurred.
+An unspecified error has occurred.
=back
diff --git a/lib/Sys/Virt/Interface.pm b/lib/Sys/Virt/Interface.pm
index 58fa2af..8f6112a 100644
--- a/lib/Sys/Virt/Interface.pm
+++ b/lib/Sys/Virt/Interface.pm
@@ -45,7 +45,7 @@ sub _new {
my $class = ref($proto) || $proto;
my %params = @_;
- my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried";
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
my $self;
if (exists $params{name}) {
$self = Sys::Virt::Interface::_lookup_by_name($con, $params{name});
diff --git a/lib/Sys/Virt/NWFilter.pm b/lib/Sys/Virt/NWFilter.pm
index 927b038..8ede8a0 100644
--- a/lib/Sys/Virt/NWFilter.pm
+++ b/lib/Sys/Virt/NWFilter.pm
@@ -45,7 +45,7 @@ sub _new {
my $class = ref($proto) || $proto;
my %params = @_;
- my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried";
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
my $self;
if (exists $params{name}) {
$self = Sys::Virt::NWFilter::_lookup_by_name($con, $params{name});
diff --git a/lib/Sys/Virt/Network.pm b/lib/Sys/Virt/Network.pm
index d90b58b..415e629 100644
--- a/lib/Sys/Virt/Network.pm
+++ b/lib/Sys/Virt/Network.pm
@@ -45,7 +45,7 @@ sub _new {
my $class = ref($proto) || $proto;
my %params = @_;
- my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried";
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
my $self;
if (exists $params{name}) {
$self = Sys::Virt::Network::_lookup_by_name($con, $params{name});
@@ -363,7 +363,7 @@ Network lifecycle events
The following constants allow network lifecycle change events to be
interpreted. The events contain both a state change, and a
-reason though the reason is currently unsed.
+reason though the reason is currently unused.
=over 4
diff --git a/lib/Sys/Virt/NodeDevice.pm b/lib/Sys/Virt/NodeDevice.pm
index 0539b9e..1ca3fa3 100644
--- a/lib/Sys/Virt/NodeDevice.pm
+++ b/lib/Sys/Virt/NodeDevice.pm
@@ -47,7 +47,7 @@ sub _new {
my $class = ref($proto) || $proto;
my %params = @_;
- my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried";
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
my $self;
if (exists $params{name}) {
$self = Sys::Virt::NodeDevice::_lookup_by_name($con, $params{name});
@@ -201,7 +201,7 @@ Node device config update events
The following constants allow node device lifecycle change events to be
interpreted. The events contain both a state change, and a
-reason though the reason is currently unsed.
+reason though the reason is currently unused.
=over 4
diff --git a/lib/Sys/Virt/Secret.pm b/lib/Sys/Virt/Secret.pm
index 0c6a021..a5ae9eb 100644
--- a/lib/Sys/Virt/Secret.pm
+++ b/lib/Sys/Virt/Secret.pm
@@ -45,7 +45,7 @@ sub _new {
my $class = ref($proto) || $proto;
my %params = @_;
- my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried";
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
my $self;
if (exists $params{usageID} ||
exists $params{usageType}) {
@@ -200,7 +200,7 @@ Secret value change events
The following constants allow secret lifecycle change events to be
interpreted. The events contain both a state change, and a
-reason though the reason is currently unsed.
+reason though the reason is currently unused.
=over 4
diff --git a/lib/Sys/Virt/StoragePool.pm b/lib/Sys/Virt/StoragePool.pm
index f4d5696..3c8abda 100644
--- a/lib/Sys/Virt/StoragePool.pm
+++ b/lib/Sys/Virt/StoragePool.pm
@@ -47,7 +47,7 @@ sub _new {
my $class = ref($proto) || $proto;
my %params = @_;
- my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried";
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
my $self;
if (exists $params{name}) {
$self = Sys::Virt::StoragePool::_lookup_by_name($con, $params{name});
@@ -496,7 +496,7 @@ Storage pool volume refresh events
The following constants allow storage pool lifecycle change events
to be interpreted. The events contain both a state change, and a
-reason though the reason is currently unsed.
+reason though the reason is currently unused.
=over 4
diff --git a/lib/Sys/Virt/StorageVol.pm b/lib/Sys/Virt/StorageVol.pm
index 82c3df2..917eb82 100644
--- a/lib/Sys/Virt/StorageVol.pm
+++ b/lib/Sys/Virt/StorageVol.pm
@@ -48,16 +48,16 @@ sub _new {
my $self;
if (exists $params{name}) {
- my $pool = exists $params{pool} ? $params{pool} : die "pool parameter is requried";
+ my $pool = exists $params{pool} ? $params{pool} : die "pool parameter is required";
$self = Sys::Virt::StorageVol::_lookup_by_name($pool, $params{name});
} elsif (exists $params{key}) {
- my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried";
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
$self = Sys::Virt::StorageVol::_lookup_by_key($con, $params{key});
} elsif (exists $params{path}) {
- my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried";
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
$self = Sys::Virt::StorageVol::_lookup_by_path($con, $params{path});
} elsif (exists $params{xml}) {
- my $pool = exists $params{pool} ? $params{pool} : die "pool parameter is requried";
+ my $pool = exists $params{pool} ? $params{pool} : die "pool parameter is required";
if ($params{clone}) {
$self = Sys::Virt::StorageVol::_create_xml_from($pool, $params{xml}, $params{clone}, 0);
} else {
diff --git a/lib/Sys/Virt/Stream.pm b/lib/Sys/Virt/Stream.pm
index a2fbc2b..9e4855e 100644
--- a/lib/Sys/Virt/Stream.pm
+++ b/lib/Sys/Virt/Stream.pm
@@ -44,7 +44,7 @@ sub _new {
my $class = ref($proto) || $proto;
my %params = @_;
- my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried";
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
my $self = Sys::Virt::Stream::_new_obj($con, $params{flags});
bless $self, $class;
--
2.14.1
6 years, 11 months
[libvirt] [PATCH] libvirt-guests: make async stop work with transient guest domains
by Vincent Bernat
After being stopped, a transient guest domain doesn't appear in the
list of guests anymore. Therefore, we can't get its state anymore. The
branch handling this case displays an error message on stdout. This
error message confuses the script which expects to get a list of
"still up" guests. We just remove the message.
Also, since we can't get a name, display the UUID of the stopped
domain.
---
tools/libvirt-guests.sh.in | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
index 8a158cca434d..e272325f7d5d 100644
--- a/tools/libvirt-guests.sh.in
+++ b/tools/libvirt-guests.sh.in
@@ -337,8 +337,6 @@ check_guests_shutdown()
guests_up=
for guest in $guests; do
if ! guest_is_on "$uri" "$guest" >/dev/null 2>&1; then
- eval_gettext "Failed to determine state of guest: \$guest. Not tracking it anymore."
- echo
continue
fi
if "$guest_running"; then
@@ -363,6 +361,7 @@ print_guests_shutdown()
esac
name=$(guest_name "$uri" "$guest")
+ [ -n "$name" ] || name="$guest"
eval_gettext "Shutdown of guest \$name complete."
echo
done
--
2.15.1
6 years, 11 months
[libvirt] [PATCH] vshReadlineOptionsGenerator: Don't add already specified options to the list
by Michal Privoznik
The current state of art is as follows:
1) vshReadlineOptionsGenerator() generate all possible --options
for given command, and then
2) vshReadlineOptionsPrune() clears out already provided ones
from the list.
Not only this brings needless memory complexity it is also not
trivial to get right. We can switch to easier approach: just
don't add already specified --options in the first step.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/vsh.c | 80 +++++++++++++++----------------------------------------------
1 file changed, 19 insertions(+), 61 deletions(-)
diff --git a/tools/vsh.c b/tools/vsh.c
index 4426c08d6..a99d47bfc 100644
--- a/tools/vsh.c
+++ b/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,
--
2.13.6
6 years, 11 months
[libvirt] [jenkins-ci PATCH] guests: Enable readline compat on FreeBSD CURRENT
by Andrea Bolognani
FreeBSD 10 is the only version *not* to need the compat hack,
so special-case it instead of the other way around.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
guests/tasks/compat.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/guests/tasks/compat.yml b/guests/tasks/compat.yml
index 001b5c6..d48834b 100644
--- a/guests/tasks/compat.yml
+++ b/guests/tasks/compat.yml
@@ -15,8 +15,8 @@
when:
- os_name == 'FreeBSD'
-# Same as above, except we only need to do it on FreeBSD 11 because
-# FreeBSD 10 shipped (an old version of) readline in the base system
+# Same as above, except we only need to do it on FreeBSD 11 and later
+# because FreeBSD 10 shipped (an old version of) readline in the base system
- name: Create compatibility symlinks
file:
src: '/usr/local/{{ item }}'
@@ -28,4 +28,4 @@
- lib/libreadline.so
when:
- os_name == 'FreeBSD'
- - os_version == '11'
+ - os_version != '10'
--
2.14.3
6 years, 11 months
[libvirt] [PATCH v2] virsh: fix build without readline
by Roman Bogorodskiy
Completion in virsh is enabled when readline is available. In order to
fix build when it's not available, do the following:
* Unconditionally add virsh-completer.[ch] and
virt-admin-completer.[ch] to the build, and provide stub functions
for when readline is not available. This way virsh builds without
complaining about missing symbols used for 'completer' in
vshCmdOptDef;
* In cmdComplete(), mark unused arguments when there's no readline
with ATTRIBUTE_UNUSED.
---
tools/Makefile.am | 20 ++------------------
tools/virsh-completer.c | 23 +++++++++++++++++++++++
tools/virt-admin-completer.c | 12 ++++++++++++
tools/vsh.c | 2 +-
4 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 48125f516..8cb66db7d 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -229,17 +229,9 @@ virsh_SOURCES = \
virsh-snapshot.c virsh-snapshot.h \
virsh-util.c virsh-util.h \
virsh-volume.c virsh-volume.h \
+ virsh-completer.c virsh-completer.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) \
diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index 48dd9fbc2..fd92ee8db 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -31,6 +31,7 @@
#include "virxml.h"
+#ifdef WITH_READLINE
char **
virshDomainNameCompleter(vshControl *ctl,
const vshCmd *cmd ATTRIBUTE_UNUSED,
@@ -147,3 +148,25 @@ virshDomainInterfaceCompleter(vshControl *ctl,
virStringListFree(ret);
return NULL;
}
+#else
+char **
+virshDomainNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
+ const vshCmd *cmd ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virCheckFlags(-1, NULL);
+
+ return NULL;
+}
+
+
+char **
+virshDomainInterfaceCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
+ const vshCmd *cmd ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virCheckFlags(-1, NULL);
+
+ return NULL;
+}
+#endif /* WITH_READLINE */
diff --git a/tools/virt-admin-completer.c b/tools/virt-admin-completer.c
index 2cd471f32..a432f0977 100644
--- a/tools/virt-admin-completer.c
+++ b/tools/virt-admin-completer.c
@@ -30,6 +30,7 @@
#include "virstring.h"
+#ifdef WITH_READLINE
char **
vshAdmServerCompleter(vshControl *ctl,
const vshCmd *cmd ATTRIBUTE_UNUSED,
@@ -74,3 +75,14 @@ vshAdmServerCompleter(vshControl *ctl,
VIR_FREE(ret);
return ret;
}
+#else
+char **
+vshAdmServerCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
+ const vshCmd *cmd ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virCheckFlags(-1, NULL);
+
+ return NULL;
+}
+#endif /* WITH_READLINE */
diff --git a/tools/vsh.c b/tools/vsh.c
index 4426c08d6..59c8a440e 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3500,7 +3500,7 @@ const vshCmdInfo info_complete[] = {
};
bool
-cmdComplete(vshControl *ctl, const vshCmd *cmd)
+cmdComplete(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
bool ret = false;
#ifdef WITH_READLINE
--
2.15.1
6 years, 11 months