[libvirt] [PATCH] security_selinux: Fix crash in virSecuritySELinuxRestoreFileLabel
by Shanzhi Yu
when failed to boot a guest, virSecuritySELinuxRestoreFileLabel
will be called eventually to reset security label, which will
lead a crash if pass null to virFileResolveLink(path, &newpath).
https://bugzilla.redhat.com/show_bug.cgi?id=1300532
Signed-off-by: Shanzhi Yu <shyu(a)redhat.com>
---
src/security/security_selinux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 9e98635..c8a7553 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1026,7 +1026,7 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManagerPtr mgr,
VIR_INFO("Restoring SELinux context on '%s'", path);
- if (virFileResolveLink(path, &newpath) < 0) {
+ if (path && virFileResolveLink(path, &newpath) < 0) {
VIR_WARN("cannot resolve symlink %s: %s", path,
virStrerror(errno, ebuf, sizeof(ebuf)));
goto err;
--
1.8.3.1
8 years, 10 months
[libvirt] [PATCH] libxl: dispose libxl_dominfo after libxl_domain_info()
by Joao Martins
As suggested in a previous thread [0] this patch adds some missing calls
to libxl_dominfo_dispose when doing some of the libxl_domain_info
operations which would otherwise lead to memory leaks.
[0]
https://www.redhat.com/archives/libvir-list/2015-September/msg00519.html
Signed-off-by: Joao Martins <joao.m.martins(a)oracle.com>
---
src/libxl/libxl_driver.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 73ed448..a449730 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -358,6 +358,8 @@ libxlReconnectDomain(virDomainObjPtr vm,
virObjectLock(vm);
+ libxl_dominfo_init(&d_info);
+
/* Does domain still exist? */
rc = libxl_domain_info(cfg->ctx, &d_info, vm->def->id);
if (rc == ERROR_INVAL) {
@@ -389,11 +391,13 @@ libxlReconnectDomain(virDomainObjPtr vm,
/* Enable domain death events */
libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->deathW);
+ libxl_dominfo_dispose(&d_info);
virObjectUnlock(vm);
virObjectUnref(cfg);
return 0;
out:
+ libxl_dominfo_dispose(&d_info);
libxlDomainCleanup(driver, vm);
if (!vm->persistent)
virDomainObjListRemoveLocked(driver->domains, vm);
@@ -1598,6 +1602,8 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
info->cpuTime = d_info.cpu_time;
info->memory = d_info.current_memkb;
info->maxMem = d_info.max_memkb;
+
+ libxl_dominfo_dispose(&d_info);
}
info->state = virDomainObjGetState(vm, NULL);
--
2.1.4
8 years, 10 months
[libvirt] [PATCH] virsh: Don't fetch status for all domains in cmdList
by Michal Privoznik
We are getting the list of domains and after that we iterate over
the list and try to get status for each domain hoping it will
skip over domains that disappeared meanwhile. However, this
solution to race is bogus - domain may disappear right after we
have checked its state and before we exec another API over it
(e.g. virDomainHasManagedSaveImage()). Also, when printing just
names or uuids (list --name / --uuid) we issue APIs to obtain the
values, however these require no RPC call as all requested info
is in virDomain object that client already has.
Therefore move the status obtaining only to the place that really
needs it.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-domain-monitor.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 7eb387d..7dcbc5c 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1876,17 +1876,17 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
else
ignore_value(virStrcpyStatic(id_buf, "-"));
- state = virshDomainState(ctl, dom, NULL);
-
- /* Domain could've been removed in the meantime */
- if (state < 0)
- continue;
-
- if (optTable && managed && state == VIR_DOMAIN_SHUTOFF &&
- virDomainHasManagedSaveImage(dom, 0) > 0)
- state = -2;
-
if (optTable) {
+ state = virshDomainState(ctl, dom, NULL);
+
+ /* Domain could've been removed in the meantime */
+ if (state < 0)
+ continue;
+
+ if (managed && state == VIR_DOMAIN_SHUTOFF &&
+ virDomainHasManagedSaveImage(dom, 0) > 0)
+ state = -2;
+
if (optTitle) {
if (!(title = virshGetDomainDescription(ctl, dom, true, 0)))
goto cleanup;
--
2.4.10
8 years, 10 months
[libvirt] [PATCH] build: predictably generate systemtap tapsets (bz 1173641)
by Cole Robinson
The generated output is dependent on perl hashtable ordering, which
gives different results for i686 and x86_64. Fix this by sorting
the hash keys before iterating over them
https://bugzilla.redhat.com/show_bug.cgi?id=1173641
---
src/rpc/gensystemtap.pl | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/rpc/gensystemtap.pl b/src/rpc/gensystemtap.pl
index 2467300..7b80fbf 100755
--- a/src/rpc/gensystemtap.pl
+++ b/src/rpc/gensystemtap.pl
@@ -72,7 +72,7 @@ function libvirt_rpc_auth_name(type, verbose)
{
EOF
my $first = 1;
-foreach my $type (keys %auth) {
+foreach my $type (sort(keys %auth)) {
my $cond = $first ? "if" : "} else if";
$first = 0;
print " $cond (type == ", $type, ") {\n";
@@ -95,7 +95,7 @@ function libvirt_rpc_type_name(type, verbose)
{
EOF
$first = 1;
-foreach my $type (keys %type) {
+foreach my $type (sort(keys %type)) {
my $cond = $first ? "if" : "} else if";
$first = 0;
print " $cond (type == ", $type, ") {\n";
@@ -118,7 +118,7 @@ function libvirt_rpc_status_name(status, verbose)
{
EOF
$first = 1;
-foreach my $status (keys %status) {
+foreach my $status (sort(keys %status)) {
my $cond = $first ? "if" : "} else if";
$first = 0;
print " $cond (status == ", $status, ") {\n";
@@ -141,7 +141,7 @@ function libvirt_rpc_program_name(program, verbose)
{
EOF
$first = 1;
-foreach my $prog (keys %funcs) {
+foreach my $prog (sort(keys %funcs)) {
my $cond = $first ? "if" : "} else if";
$first = 0;
print " $cond (program == ", $funcs{$prog}->{id}, ") {\n";
@@ -165,7 +165,7 @@ function libvirt_rpc_procedure_name(program, version, proc, verbose)
{
EOF
$first = 1;
-foreach my $prog (keys %funcs) {
+foreach my $prog (sort(keys %funcs)) {
my $cond = $first ? "if" : "} else if";
$first = 0;
print " $cond (program == ", $funcs{$prog}->{id}, " && version == ", $funcs{$prog}->{version}, ") {\n";
--
2.5.0
8 years, 10 months
[libvirt] [PATCH] docs: fix syntax-check long line error
by Cole Robinson
---
Pushed as trivial
docs/Makefile.am | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 231aa4e..02eca64 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -220,7 +220,8 @@ $(srcdir)/hvsupport.html.in: $(srcdir)/hvsupport.pl $(api_DATA) \
%.png: %.fig
convert -rotate 90 $< $@
-%.html.tmp: %.html.in site.xsl subsite.xsl page.xsl sitemap.html.in $(acl_generated)
+%.html.tmp: %.html.in site.xsl subsite.xsl page.xsl \
+ sitemap.html.in $(acl_generated)
@if [ -x $(XSLTPROC) ] ; then \
echo "Generating $@"; \
name=`echo $@ | sed -e 's/.tmp//'`; \
--
2.5.0
8 years, 10 months
[libvirt] [PATCH v3] libvirtd: Increase NL buffer size for lots of interface
by Leno Hou
1. When switching CPUs to offline/online in a system more than 128 cpus
2. When using virsh to destroy domain in a system with more interface
All of above happens nl_recv returned with error: No buffer space available.
This patch sets the socket buffer size to 128K and turns on message peeking
for nl_recv,as this would solve this problem totally and permanetly.
Signed-off-by: Leno Hou <houqy(a)linux.vnet.ibm.com>
Cc: Wenyi Gao <wenyi(a)linux.vnet.ibm.com>
CC: Laine Stump <laine(a)laine.org>
CC: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virnetlink.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 679b48e..ea65cbc 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -65,10 +65,12 @@ struct virNetlinkEventHandle {
# ifdef HAVE_LIBNL1
# define virNetlinkAlloc nl_handle_alloc
+# define virSocketSetBufferSize nl_set_buffer_size
# define virNetlinkFree nl_handle_destroy
typedef struct nl_handle virNetlinkHandle;
# else
# define virNetlinkAlloc nl_socket_alloc
+# define virSocketSetBufferSize nl_socket_set_buffer_size
# define virNetlinkFree nl_socket_free
typedef struct nl_sock virNetlinkHandle;
# endif
@@ -696,6 +698,14 @@ virNetlinkEventServiceStart(unsigned int protocol, unsigned int groups)
goto error_server;
}
+ if (virSocketSetBufferSize(srv->netlinknh, 131702, 0) < 0) {
+ virReportSystemError(errno,
+ "%s",_("cannot set netlink socket buffer size to 128k"));
+ goto error_server;
+ }
+
+ nl_socket_enable_msg_peek(srv->netlinknh);
+
if ((srv->eventwatch = virEventAddHandle(fd,
VIR_EVENT_HANDLE_READABLE,
virNetlinkEventCallback,
--
1.9.1
8 years, 10 months
[libvirt] [PATCH] qemuDomainReboot: use fakeReboot=true only for acpi mode
by Dmitry Andreev
When acpi is used to reboot/shutdown qemu domain, qemu emits
SHUTDOWN event. Libvirt uses fakeReboot variable in order to
differentiate reboot or shutdown. fakeReboot value is reseted
to false after domain restart/reset.
When mode=agent is used to reboot qemu domain, qemu doesn't emit
SHUTDOWN event and libvirt doesn't reset fakeReboot value to false.
In this case next 'shutdown -h now' performs reboot. That's why
we don't need to set fakeReboot=true for mode=agent.
---
src/qemu/qemu_driver.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8ccf68b..e46404b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2068,8 +2068,6 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags)
goto endjob;
}
- qemuDomainSetFakeReboot(driver, vm, isReboot);
-
if (useAgent) {
qemuDomainObjEnterAgent(vm);
ret = qemuAgentShutdown(priv->agent, agentFlag);
@@ -2096,6 +2094,7 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags)
#if WITH_YAJL
}
#endif
+ qemuDomainSetFakeReboot(driver, vm, isReboot);
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSystemPowerdown(priv->mon);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
--
1.8.3.1
8 years, 10 months
[libvirt] [PATCH] docs: fix generation of docs from VPATH build
by Daniel P. Berrange
When generating docs in a VPATH build we get a failure to
create a file due to the 'internals' subdir not existing:
Generating internals/locking.html.tmp
/bin/sh: line 3: internals/locking.html.tmp: No such file or directory
rm: cannot remove ‘internals/locking.html.tmp’: No such file or directory
Makefile:2229: recipe for target 'internals/locking.html.tmp' failed
make: *** [internals/locking.html.tmp] Error 1
For some reason, make has decided to run the target
%.html.tmp: %.html.in site.xsl page.xsl sitemap.html.in $(acl_generated)
instead of the target
internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in
Removing '$(acl_generated)' from the first target, inexplicably
causes make to now run the correct target for the internals/
files.
Rather than figure this out, lets just combine the two targets
into one.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
docs/Makefile.am | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/docs/Makefile.am b/docs/Makefile.am
index fb53a45..231aa4e 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -220,21 +220,20 @@ $(srcdir)/hvsupport.html.in: $(srcdir)/hvsupport.pl $(api_DATA) \
%.png: %.fig
convert -rotate 90 $< $@
-internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in
+%.html.tmp: %.html.in site.xsl subsite.xsl page.xsl sitemap.html.in $(acl_generated)
@if [ -x $(XSLTPROC) ] ; then \
echo "Generating $@"; \
- $(MKDIR_P) internals; \
name=`echo $@ | sed -e 's/.tmp//'`; \
+ dir=`dirname $@` ; \
+ if test "$$dir" = "."; \
+ then \
+ style=site.xsl; \
+ else \
+ $(MKDIR_P) $$dir; \
+ style=subsite.xsl; \
+ fi; \
$(XSLTPROC) --stringparam pagename $$name --nonet \
- $(top_srcdir)/docs/subsite.xsl $< > $@ \
- || { rm $@ && exit 1; }; fi
-
-%.html.tmp: %.html.in site.xsl page.xsl sitemap.html.in $(acl_generated)
- @if [ -x $(XSLTPROC) ] ; then \
- echo "Generating $@"; \
- name=`echo $@ | sed -e 's/.tmp//'`; \
- $(XSLTPROC) --stringparam pagename $$name --nonet \
- $(top_srcdir)/docs/site.xsl $< > $@ \
+ $(top_srcdir)/docs/$$style $< > $@ \
|| { rm $@ && exit 1; }; fi
%.html: %.html.tmp
--
2.5.0
8 years, 10 months
Re: [libvirt] [PATCH LIBVIRT] libxl: Support cmdline= in xl config files
by Ian Campbell
I went to ping this but noticed that I had sent it to "jimfehlig" (i.e. no
domain), so no wonder there was no reply!
To: line fixed here, let me know if you would prefer a resend.
Ian.
On Wed, 2015-12-16 at 12:09 +0000, Ian Campbell wrote:
> ... and consolidate the cmdline/extra/root parsing to facilitate doing
> so.
>
> The logic is the same as xl's parse_cmdline from the current xen.git master
> branch (e6f0e099d2c17de47fd86e817b1998db903cab61), except I was unable
> to figure out how/where to route the warning about ignoring
> root+extra if cmdline was specified.
>
> Signed-off-by: Ian Campbell <ian.campbell(a)citrix.com>
> ---
> src/xenconfig/xen_xl.c | 62 ++++++++++++++++++++++++++++++------------
> --------
> 1 file changed, 37 insertions(+), 25 deletions(-)
>
> diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
> index 91cdff6..ba8b938 100644
> --- a/src/xenconfig/xen_xl.c
> +++ b/src/xenconfig/xen_xl.c
> @@ -58,11 +58,45 @@ extern int xlu_disk_parse(XLU_Config *cfg,
> libxl_device_disk *disk);
> #endif
>
> +static int xenParseCmdline(virConfPtr conf, char **r_cmdline)
> +{
> + char *cmdline = NULL;
> + const char *root = NULL, *extra = NULL, *buf = NULL;
> +
> + if (xenConfigGetString(conf, "cmdline", &buf, NULL) < 0)
> + return -1;
> +
> + if (xenConfigGetString(conf, "root", &root, NULL) < 0)
> + return -1;
> +
> + if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
> + return -1;
> +
> + if (buf) {
> + if (VIR_STRDUP(cmdline, buf) < 0)
> + return -1;
> + /* root or extra are ignored in this case. */
> + } else {
> + if (root && extra) {
> + if (virAsprintf(&cmdline, "root=%s %s", root, extra) < 0)
> + return -1;
> + } else if (root) {
> + if (virAsprintf(&cmdline, "root=%s", root) < 0)
> + return -1;
> + } else if (extra) {
> + if (VIR_STRDUP(cmdline, extra) < 0)
> + return -1;
> + }
> + }
> +
> + *r_cmdline = cmdline;
> + return 0;
> +}
> +
> static int
> xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
> {
> size_t i;
> - const char *extra, *root;
>
> if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
> const char *boot;
> @@ -84,19 +118,8 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def,
> virCapsPtr caps)
> if (xenConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) <
> 0)
> return -1;
>
> - if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
> - return -1;
> -
> - if (xenConfigGetString(conf, "root", &root, NULL) < 0)
> + if (xenParseCmdline(conf, &def->os.cmdline) < 0)
> return -1;
> -
> - if (root) {
> - if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra)
> < 0)
> - return -1;
> - } else {
> - if (VIR_STRDUP(def->os.cmdline, extra) < 0)
> - return -1;
> - }
> #endif
>
> if (xenConfigGetString(conf, "boot", &boot, "c") < 0)
> @@ -132,19 +155,8 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def,
> virCapsPtr caps)
> if (xenConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) <
> 0)
> return -1;
>
> - if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
> - return -1;
> -
> - if (xenConfigGetString(conf, "root", &root, NULL) < 0)
> + if (xenParseCmdline(conf, &def->os.cmdline) < 0)
> return -1;
> -
> - if (root) {
> - if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra)
> < 0)
> - return -1;
> - } else {
> - if (VIR_STRDUP(def->os.cmdline, extra) < 0)
> - return -1;
> - }
> }
>
> return 0;
8 years, 10 months
[libvirt] [PATCH 0/2] Fix problem generating partition names for multipath device
by John Ferlan
Originally posted as an RFC:
http://www.redhat.com/archives/libvir-list/2015-December/msg00200.html
I've made further adjustments/changes and actually tested in a multipath
environment configured with the issue.
For these patches, rather than making a "general" flag for the pool,
I chose to add an attribute to the <source> 'device'. This way it was
much more clear what the attribute was affecting.
Additionally, it turned out that the issue was showing up for both
'user_friendly_names' and for custom 'alias' name entries in the
/etc/multipath.conf file so rather than being a user_friendly_name
type flag - I just chose to specific state what it was - a way to
not have the partition separator flag "p" added to the generated name.
Also it was a bit more difficult to describe the use of the flag
especially when it was so specific to one backing store type.
John Ferlan (2):
conf: Add storage pool device attribute part_separator
storage: Add new flag for libvirt_parthelper
docs/formatstorage.html.in | 30 ++++++++++++++++++++--
docs/schemas/storagepool.rng | 5 ++++
src/conf/storage_conf.c | 26 +++++++++++++++++--
src/conf/storage_conf.h | 3 ++-
src/storage/parthelper.c | 15 ++++++++---
src/storage/storage_backend_disk.c | 11 +++++++-
.../pool-disk-device-nopartsep.xml | 14 ++++++++++
.../pool-disk-device-nopartsep.xml | 14 ++++++++++
tests/storagepoolxml2xmltest.c | 1 +
9 files changed, 110 insertions(+), 9 deletions(-)
create mode 100644 tests/storagepoolxml2xmlin/pool-disk-device-nopartsep.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-disk-device-nopartsep.xml
--
2.5.0
8 years, 10 months