[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
7 years, 2 months
[libvirt] [jenkins-ci PATCH] guests: Install libtirpc when building libvirt
by Andrea Bolognani
Recent glibc versions don't include an RPC library anymore, so
we need to make sure an alternative implementation is available
for libvirt to use.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
guests/vars/mappings.yml | 4 ++++
guests/vars/projects/libvirt.yml | 1 +
2 files changed, 5 insertions(+)
diff --git a/guests/vars/mappings.yml b/guests/vars/mappings.yml
index 9c194d0..e669b6c 100644
--- a/guests/vars/mappings.yml
+++ b/guests/vars/mappings.yml
@@ -279,6 +279,10 @@ mappings:
pkg: libssh2
rpm: libssh2-devel
+ libtirpc:
+ deb: libtirpc-dev
+ rpm: libtirpc-devel
+
libtool:
default: libtool
Debian: libtool-bin
diff --git a/guests/vars/projects/libvirt.yml b/guests/vars/projects/libvirt.yml
index ba1e4c3..598dfc4 100644
--- a/guests/vars/projects/libvirt.yml
+++ b/guests/vars/projects/libvirt.yml
@@ -32,6 +32,7 @@ packages:
- libselinux
- libssh
- libssh2
+ - libtirpc
- libudev
- libxml2
- lvm2
--
2.14.3
7 years, 2 months
[libvirt] [PATCH] vshReadlineOptionsPrune: Fix possible leak
by Michal Privoznik
The function should prune list of --options so that options
already specified are not offered to user for completion again.
However, if the list of offered options contains a string that
doesn't start with double dash the function returns leaking
partially constructed list. There's not much benefit from trying
to roll back. Just free everything up - our only caller would do
that anyway.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/vsh.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tools/vsh.c b/tools/vsh.c
index 4426c08d6..7db0a16f1 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2798,8 +2798,17 @@ vshReadlineOptionsPrune(char ***list,
vshCmdOpt *opt = last->opts;
/* Should never happen (TM) */
- if (!list_opt)
+ if (!list_opt) {
+ /* But in case it does, we're in a tough situation
+ * because @list[0..i-1] is possibly sparse. That
+ * means if caller were to call virStringListFree
+ * over it some memory is definitely going to be
+ * leaked. The best we can do is to free from list[i]
+ * as our only caller is just fine with it. */
+ virStringListFree(list[i]);
+ virStringListFree(newList);
return -1;
+ }
while (opt) {
if (STREQ(opt->def->name, list_opt)) {
--
2.13.6
7 years, 2 months
[libvirt] [PATCH] virsh: fix build without readline
by Roman Bogorodskiy
Completion in virsh is enabled when readline is available. However,
when it's not available, we should:
* avoid defining completers with completion functions;
* in cmdComplete(), mark unused arguments when there's no readline with
ATTRIBUTE_UNUSED.
---
tools/virsh-domain-monitor.c | 6 ++++++
tools/virsh-domain.c | 6 ++++++
tools/virsh.h | 11 ++++++++++-
tools/virt-admin.c | 14 ++++++++++++++
tools/vsh.c | 2 +-
5 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 32a42707e..0df20eea0 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -659,7 +659,9 @@ static const vshCmdOptDef opts_domif_getlink[] = {
{.name = "interface",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#if WITH_READLINE
.completer = virshDomainInterfaceCompleter,
+#endif
.help = N_("interface device (MAC Address)")
},
{.name = "persistent",
@@ -996,7 +998,9 @@ static const vshCmdOptDef opts_domifstat[] = {
{.name = "interface",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#ifdef WITH_READLINE
.completer = virshDomainInterfaceCompleter,
+#endif
.help = N_("interface device specified by name or MAC Address")
},
{.name = NULL}
@@ -2151,7 +2155,9 @@ static const vshCmdOptDef opts_domifaddr[] = {
{.name = "interface",
.type = VSH_OT_STRING,
.flags = VSH_OFLAG_NONE,
+#ifdef WITH_READLINE
.completer = virshDomainInterfaceCompleter,
+#endif
.help = N_("network interface name")},
{.name = "full",
.type = VSH_OT_BOOL,
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0f329d6d7..c5511adbf 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2977,7 +2977,9 @@ static const vshCmdOptDef opts_domif_setlink[] = {
{.name = "interface",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#ifdef WITH_READLINE
.completer = virshDomainInterfaceCompleter,
+#endif
.help = N_("interface device (MAC Address)")
},
{.name = "state",
@@ -3148,7 +3150,9 @@ static const vshCmdOptDef opts_domiftune[] = {
{.name = "interface",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#ifdef WITH_READLINE
.completer = virshDomainInterfaceCompleter,
+#endif
.help = N_("interface device (MAC Address)")
},
{.name = "inbound",
@@ -11985,8 +11989,10 @@ static const vshCmdOptDef opts_detach_interface[] = {
},
{.name = "mac",
.type = VSH_OT_STRING,
+#ifdef WITH_READLINE
.completer = virshDomainInterfaceCompleter,
.completer_flags = VIRSH_DOMAIN_INTERFACE_COMPLETER_MAC,
+#endif
.help = N_("MAC address")
},
VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
diff --git a/tools/virsh.h b/tools/virsh.h
index 528e04558..b3cb15ac4 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -71,7 +71,8 @@
.help = _helpstr \
}
-# define VIRSH_COMMON_OPT_DOMAIN(_helpstr, cflags) \
+# ifdef WITH_READLINE
+# define VIRSH_COMMON_OPT_DOMAIN(_helpstr, cflags) \
{.name = "domain", \
.type = VSH_OT_DATA, \
.flags = VSH_OFLAG_REQ, \
@@ -79,6 +80,14 @@
.completer = virshDomainNameCompleter, \
.completer_flags = cflags, \
}
+# else
+# define VIRSH_COMMON_OPT_DOMAIN(_helpstr, cflags) \
+ {.name = "domain", \
+ .type = VSH_OT_DATA, \
+ .flags = VSH_OFLAG_REQ, \
+ .help = _helpstr, \
+ }
+# endif
# define VIRSH_COMMON_OPT_CONFIG(_helpstr) \
{.name = "config", \
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index c86b5763a..ac4d00dd7 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -429,7 +429,9 @@ static const vshCmdOptDef opts_srv_threadpool_info[] = {
{.name = "server",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#ifdef WITH_READLINE
.completer = vshAdmServerCompleter,
+#endif
.help = N_("Server to retrieve threadpool attributes from."),
},
{.name = NULL}
@@ -491,7 +493,9 @@ static const vshCmdOptDef opts_srv_threadpool_set[] = {
{.name = "server",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#ifdef WITH_READLINE
.completer = vshAdmServerCompleter,
+#endif
.help = N_("Server to alter threadpool attributes on."),
},
{.name = "min-workers",
@@ -598,7 +602,9 @@ static const vshCmdOptDef opts_srv_clients_list[] = {
{.name = "server",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#ifdef WITH_READLINE
.completer = vshAdmServerCompleter,
+#endif
.help = N_("server which to list connected clients from"),
},
{.name = NULL}
@@ -680,7 +686,9 @@ static const vshCmdOptDef opts_client_info[] = {
{.name = "server",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#ifdef WITH_READLINE
.completer = vshAdmServerCompleter,
+#endif
.help = N_("server to which <client> is connected to"),
},
{.name = "client",
@@ -768,7 +776,9 @@ static const vshCmdOptDef opts_client_disconnect[] = {
{.name = "server",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#ifdef WITH_READLINE
.completer = vshAdmServerCompleter,
+#endif
.help = N_("server which the client is currently connected to"),
},
{.name = "client",
@@ -834,7 +844,9 @@ static const vshCmdOptDef opts_srv_clients_info[] = {
{.name = "server",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#ifdef WITH_READLINE
.completer = vshAdmServerCompleter,
+#endif
.help = N_("Server to retrieve the client limits from."),
},
{.name = NULL}
@@ -894,7 +906,9 @@ static const vshCmdOptDef opts_srv_clients_set[] = {
{.name = "server",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+#ifdef WITH_READLINE
.completer = vshAdmServerCompleter,
+#endif
.help = N_("Server to alter the client-related configuration limits on."),
},
{.name = "max-clients",
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
7 years, 2 months
[libvirt] [resend][PATCH] deamon: use default value if ca_file, cert_file or key_file not set
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
As the description of daemon/libvirtd.conf, setting
key_file, cert_file or key_file will override the default value.
But if we set any one of them, we need to set all the rest of them.
This patch set default value to them as daemon/libvirtd.conf
described.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
daemon/libvirtd.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 6d3b83355..93983f63b 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -493,19 +493,28 @@ daemonSetupNetworking(virNetServerPtr srv,
config->cert_file ||
config->key_file) {
if (!config->ca_file) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("No CA certificate path set to match server key/cert"));
- goto cleanup;
+ VIR_WARN("Using default path for ca_file");
+ if (VIR_STRDUP(config->ca_file, LIBVIRT_CACERT) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("No CA certificate path set to match server key/cert"));
+ goto cleanup;
+ }
}
if (!config->cert_file) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("No server certificate path set to match server key"));
- goto cleanup;
+ VIR_WARN("Using default path for cert_file");
+ if (VIR_STRDUP(config->cert_file, LIBVIRT_SERVERCERT) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("No server certificate path set to match server key"));
+ goto cleanup;
+ }
}
if (!config->key_file) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("No server key path set to match server cert"));
- goto cleanup;
+ VIR_WARN("Using default path for key_file");
+ if (VIR_STRDUP(config->key_file, LIBVIRT_SERVERKEY) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("No server key path set to match server cert"));
+ goto cleanup;
+ }
}
VIR_DEBUG("Using CA='%s' cert='%s' key='%s'",
config->ca_file, config->cert_file, config->key_file);
--
2.14.3
7 years, 2 months
[libvirt] [PATCH v2] domain_conf: skip boot order check of CD-ROM or floppy device when change-media
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
If we insert or eject a CD-ROM/floppy device by:
'virsh change-media VM --eject/--insert some.iso --live',
and the original CD-ROM device was configed with a boot order,
we may get:
unsupported configuration: boot order 2 is already used by another device
We just updated 'source file' section rather than hotplug a new device.
This check should be skipped in this case.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
v2:
commit message updated
remove ATTRIBUTE_UNUSED from @device
src/conf/domain_conf.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a1c25060f..e006cea0a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -26881,17 +26881,26 @@ virDomainDeviceIsUSB(virDomainDeviceDefPtr dev)
static int
virDomainDeviceInfoCheckBootIndex(virDomainDefPtr def ATTRIBUTE_UNUSED,
- virDomainDeviceDefPtr device ATTRIBUTE_UNUSED,
+ virDomainDeviceDefPtr device,
virDomainDeviceInfoPtr info,
void *opaque)
{
virDomainDeviceInfoPtr newinfo = opaque;
+ virDomainDiskDefPtr disk = device->data.disk;
+ int disk_device = disk->device;
if (info->bootIndex == newinfo->bootIndex) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("boot order %u is already used by another device"),
- newinfo->bootIndex);
- return -1;
+ /* Skip check for insert or eject CD-ROM device */
+ if (disk_device == VIR_DOMAIN_DISK_DEVICE_FLOPPY ||
+ disk_device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
+ VIR_DEBUG("Skip boot index check for floppy or CDROM");
+ return 0;
+ } else {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("boot order %u is already used by another device"),
+ newinfo->bootIndex);
+ return -1;
+ }
}
return 0;
}
--
2.14.3
7 years, 2 months
[libvirt] [PATCH v2 0/2] qemu_hotplug: introduce VIR_ERR_DEVICE_MISSING for failing to find the desired device
by Chen Hanxiao
We used VIR_ERR_OPERATION_INVALID for failing to find the desired
device.
But this error code is widely used.
This brings troubles to the project(i.e nova) powered by libvirt,
they had to analyze error messages to find out what
had happened.
Chen Hanxiao (2):
qemu_hotplug: more proper error messages when target detaching device
is not found
qemu_hotplug: introduce VIR_ERR_DEVICE_MISSING for failing to find
desired device
include/libvirt/virterror.h | 1 +
src/libvirt_private.syms | 2 ++
src/qemu/qemu_hotplug.c | 54 +++++++++++++++++++++++++++++----------------
src/util/virerror.c | 6 +++++
4 files changed, 44 insertions(+), 19 deletions(-)
--
2.14.3
7 years, 2 months
[libvirt] [PATCH python v2 0/9] Various improvements to RPM spec
by Daniel P. Berrange
Daniel P. Berrange (9):
Allow disabling of python2 RPM build
Allow override of which sub-RPMs to build
Add checks for min supported distros
Add emacs mode marker to activate rpm-spec highlighting
Adapt to rename of py2 RPMs from python- to python2- prefix
Turn on python3 sub-RPMs for RHEL > 7
Require libvirt native version matching py version by default
Fix filtering of RPM provides for .so files
Use python*_sitearch macros instead of manually defining the dir
libvirt-python.spec.in | 89 +++++++++++++++++++++++++++++++++++++++-----------
setup.py | 3 +-
2 files changed, 71 insertions(+), 21 deletions(-)
--
2.14.3
7 years, 2 months
[libvirt] [PATCH python 0/7] Misc improvements to RPM spec
by Daniel P. Berrange
Various improvements to the RPM spec to help future Fedora/RHEL maint
Daniel P. Berrange (7):
Allow disabling of python2 RPM build
Allow override of which sub-RPMs to build
Add checks for min supported distros
Add emacs mode marker to activate rpm-spec highlighting
Adapt to rename of py2 RPMs from python- to python2- prefix
Turn on python3 sub-RPMs for RHEL > 7
Require libvirt native version matching py version by default
libvirt-python.spec.in | 54 ++++++++++++++++++++++++++++++++++++++++++++++----
setup.py | 3 +--
2 files changed, 51 insertions(+), 6 deletions(-)
--
2.14.3
7 years, 2 months
[libvirt] [PATCH] fixed bug:if expand thread pool, will lose some one
by Di Wei
---
src/util/virthreadpool.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index 10f2bd2..0983ee2 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -186,6 +186,7 @@ virThreadPoolExpand(virThreadPoolPtr pool, size_t gain, bool priority)
size_t *curWorkers = priority ? &pool->nPrioWorkers : &pool->nWorkers;
size_t i = 0;
struct virThreadPoolWorkerData *data = NULL;
+ size_t oldNWorkers = *curWorkers;
if (VIR_EXPAND_N(*workers, *curWorkers, gain) < 0)
return -1;
@@ -198,7 +199,7 @@ virThreadPoolExpand(virThreadPoolPtr pool, size_t gain, bool priority)
data->cond = priority ? &pool->prioCond : &pool->cond;
data->priority = priority;
- if (virThreadCreateFull(&(*workers)[i],
+ if (virThreadCreateFull(&(*workers)[i + oldNWorkers],
false,
virThreadPoolWorker,
pool->jobFuncName,
--
2.9.3
7 years, 2 months