[libvirt] [PATCH] g_mkostemp_full: pass O_RDWR
by Ján Tomko
This flag is not implied by g_mkostemp_full, only by g_mkostemp.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
Reported-by: Bjoern Walk <bwalk(a)linux.ibm.com>
Fixes: 4ac47730408eaf91683f6502ec10541f4f711a5c
---
src/qemu/qemu_driver.c | 4 ++--
src/storage/storage_util.c | 2 +-
src/util/virlog.c | 2 +-
src/vbox/vbox_common.c | 2 +-
tests/virfiletest.c | 2 +-
tools/vsh.c | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 60f5732708..7fd87a9d76 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4024,7 +4024,7 @@ qemuDomainScreenshot(virDomainPtr dom,
if (!(tmp = g_strdup_printf("%s/qemu.screendump.XXXXXX", cfg->cacheDir)))
goto endjob;
- if ((tmp_fd = g_mkstemp_full(tmp, O_CLOEXEC, S_IRUSR | S_IWUSR)) == -1) {
+ if ((tmp_fd = g_mkstemp_full(tmp, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR)) == -1) {
virReportSystemError(errno, _("g_mkstemp(\"%s\") failed"), tmp);
goto endjob;
}
@@ -11970,7 +11970,7 @@ qemuDomainMemoryPeek(virDomainPtr dom,
goto endjob;
/* Create a temporary filename. */
- if ((fd = g_mkstemp_full(tmp, O_CLOEXEC, S_IRUSR | S_IWUSR)) == -1) {
+ if ((fd = g_mkstemp_full(tmp, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR)) == -1) {
virReportSystemError(errno,
_("g_mkstemp(\"%s\") failed"), tmp);
goto endjob;
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 6d41df8d7e..f2d8810813 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -1215,7 +1215,7 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolObjPtr pool,
if (!(secretPath = virStoragePoolObjBuildTempFilePath(pool, vol)))
goto cleanup;
- if ((fd = g_mkstemp_full(secretPath, O_CLOEXEC, S_IRUSR | S_IWUSR)) < 0) {
+ if ((fd = g_mkstemp_full(secretPath, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR)) < 0) {
virReportSystemError(errno, "%s",
_("failed to open secret file for write"));
goto error;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 05052e9d09..d45e2dd316 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -992,7 +992,7 @@ virLogOutputToJournald(virLogSourcePtr source,
* and pass an FD to the journal
*/
- if ((buffd = g_mkstemp_full(path, O_CLOEXEC, S_IRUSR | S_IWUSR)) < 0)
+ if ((buffd = g_mkstemp_full(path, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR)) < 0)
return;
if (unlink(path) < 0)
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 88ef41b5df..9e41b6767a 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -7385,7 +7385,7 @@ vboxDomainScreenshot(virDomainPtr dom,
tmp = g_strdup_printf("%s/vbox.screendump.XXXXXX", cacheDir);
- if ((tmp_fd = g_mkstemp_full(tmp, O_CLOEXEC, S_IRUSR | S_IWUSR)) == -1) {
+ if ((tmp_fd = g_mkstemp_full(tmp, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR)) == -1) {
virReportSystemError(errno, _("g_mkstemp(\"%s\") failed"), tmp);
VIR_FREE(tmp);
VBOX_RELEASE(machine);
diff --git a/tests/virfiletest.c b/tests/virfiletest.c
index 193c5bedd4..781c640e2b 100644
--- a/tests/virfiletest.c
+++ b/tests/virfiletest.c
@@ -133,7 +133,7 @@ makeSparseFile(const off_t offsets[],
off_t len = 0;
size_t i;
- if ((fd = g_mkstemp_full(path, O_CLOEXEC, S_IRUSR | S_IWUSR)) < 0)
+ if ((fd = g_mkstemp_full(path, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR)) < 0)
goto error;
if (unlink(path) < 0)
diff --git a/tools/vsh.c b/tools/vsh.c
index b5de06f26b..1076c8254b 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2400,7 +2400,7 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
tmpdir = getenv("TMPDIR");
if (!tmpdir) tmpdir = "/tmp";
ret = g_strdup_printf("%s/virshXXXXXX.xml", tmpdir);
- fd = g_mkstemp_full(ret, O_CLOEXEC, S_IRUSR | S_IWUSR);
+ fd = g_mkstemp_full(ret, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR);
if (fd == -1) {
vshError(ctl, _("g_mkstemp_full: failed to create temporary file: %s"),
virStrerror(errno, ebuf, sizeof(ebuf)));
--
2.21.0
5 years
[libvirt] Bug: virsh edit broken on master
by Bjoern Walk
Hey all,
commit 4ac47730: Use g_mkstemp_full instead of mkostemp(s) broke `virsh
edit` (at least on S390):
virsh # edit test
error: write: /tmp/virshQ7SXB0.xml: failed to write to temporary file: Bad file descriptorx
I didn't find out why, everything looks normal:
# ls -l /proc/$(pgrep virsh)/fd/
total 0
[...]
lr-x------. 1 root root 64 Nov 18 16:58 10 -> /tmp/virshAEKYB0.xml
# ls -l /tmp/virshAEKYB0.xml
-rw-------. 1 root root 0 Nov 18 16:59 /tmp/virshAEKYB0.xml
Best,
Bjoern
--
IBM Systems
Linux on Z & Virtualization Development
--------------------------------------------------
IBM Deutschland Research & Development GmbH
Schönaicher Str. 220, 71032 Böblingen
Phone: +49 7031 16 1819
--------------------------------------------------
Vorsitzende des Aufsichtsrats: Matthias Hartmann
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
5 years
[libvirt] [PATCH 0/3] A few more Coverity patches
by John Ferlan
Finally got Coverity to build with the recent build env changes.
With doing that Coverity re-examines everything and bridge_driver
generated a couple of longer term things. The virFileRewrite is
from more recent changes.
John Ferlan (3):
util: Remove unnecessary check in virFileRewrite
network: Use local variables in networkUpdatePortBandwidth
network: Check for QOS before blindly using it
src/network/bridge_driver.c | 31 ++++++++++++++++++++++---------
src/util/virfile.c | 3 +--
2 files changed, 23 insertions(+), 11 deletions(-)
--
2.20.1
5 years
[libvirt] [PATCH 0/3] Fix remote dispatch code trying to allocate 0-sized return buffers
by Erik Skultety
This happens because of the switch to glib whose method g_malloc0 actually
correctly returns NULL on size 0 which doesn't make sense to do. The outcome of
that is that because virAllocN always returns 0, the dispatch code never fails
allocation and passes the NULL pointer to the server-side public API which
actually checks that and fails.
https://bugzilla.redhat.com/show_bug.cgi?id=1772842
Erik Skultety (3):
rpc: gendispatch: Fix a couple of places adding trailing spaces
rpc: gendispatch: Add a check for zero size client-side buffers
libvirt-domain: virConnectListDomains: Return 0 on zero-size buffer
src/libvirt-domain.c | 3 +++
src/rpc/gendispatch.pl | 12 ++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
--
2.23.0
5 years
[libvirt] [PATCH] qemu: Fix NULL ptr dereference caused by qemuDomainDefFormatBufInternal
by Erik Skultety
qemuDomainDefFormatBufInternal function wasn't testing whether the CPU
was actually defined in the XML and saving such a domain resulted in the
following backtrace:
0 in qemuDomainMakeCPUMigratable (cpu=0x0)
1 in qemuDomainDefFormatBufInternal()
2 in qemuDomainDefFormatXMLInternal()
3 in qemuDomainDefFormatLive()
4 in qemuDomainSaveInternal()
5 in qemuDomainSaveFlags()
6 in qemuDomainSave()
7 in virDomainSave()
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
src/qemu/qemu_domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e14b414518..ed2a5cc7b6 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9105,7 +9105,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
goto cleanup;
}
- if (qemuDomainMakeCPUMigratable(def->cpu) < 0)
+ if (def->cpu && qemuDomainMakeCPUMigratable(def->cpu) < 0)
goto cleanup;
}
--
2.23.0
5 years
[libvirt] [PATCH v2 00/24] scripts: convert most perl scripts to python
by Daniel P. Berrangé
This series is an effort to reduce the number of different
languages we use by eliminating most use of perl in favour
of python.
This aligns with fact that the likely future build system
we'll use (meson) is written in python, and that python
is much more commonly used/understood by developers these
days than perl.
With this applied we use perl in a handful of places only:
- src/rpc/gendispatch.pl - this is a horrendously large
script and very hard to understand/follow. A straight
syntax conversion to Python would still leave a hgue
and hard to understand/follow script. It really needs
a clean room rewrite from scratch, with better structure.
- src/rpc/genprotocol.pl - fairly easy to convert, but
might be obsolete depending on approach for rewriting
gendispatch.pl, so ignored for now
- tests/oomtrace.pl - will be purge by the patches that
drop OOM handling anyway
- tools/wireshark/util/genxdrstub.pl - a very large
script, which I haven't got the courage to tackle
yet.
- cfg.mk/maint.mk - many syntax rules involve regexes
which are fed to perl. Decision on what to do
with syntax-check rules punted to another time.
- build-aux/gitlog-to-changelog
- build-aux/useless-if-before-free - Both pulled in
from gnulib. Could be rewritten quite easily if
desired, but given that we aren't maintainers of
them right now, they're ignored as they don't
really impact our developers.
In v2:
- Pulled in patch to hacking file
- Converted many more scripts
- Forced UTF-8 character set to avoid ascii codec
on py3 < 3.7
Daniel P. Berrangé (24):
docs: document that C & Python are the preferred languages
cfg.mk: fix comment detection for python semicolon check
build: force a UTF-8 locale for python
build-aux: rewrite augest test generator in Python
build-aux: rewrite po file minimizer in Python
build-aux: rewrite duplicate header checker in Python
build-aux: rewrite whitespace checker in Python
build-aux: rewrite mock inline checker in Python
build-aux: rewrite header ifdef checker in Python
src: rewrite ACL permissions checker in Python
src: rewrite symfile sorting checker in Python
src: rewrite symfile library checker in Python
src: rewrite systemtap probe generator in Python
src: rewrite systemtap function generator in Python
src: rewrite driver name checker in Python
src: rewrite driver impl checker in Python
src: rewrite ACL rule checker in Python
src: rewrite polkit ACL generator in Python
src: rewrite remote protocol checker in Python
tests: rewrite test argv line wrapper in Python
tests: rewrite qemu capability grouper in Python
tests: rewrite file access checker in Python
docs: rewrite hvsupport.html page generator in python
docs: rewrite polkit docs generator in Python
Makefile.am | 14 +-
build-aux/augeas-gentest.pl | 60 ----
build-aux/augeas-gentest.py | 72 ++++
build-aux/check-spacing.pl | 198 ----------
build-aux/check-spacing.py | 204 +++++++++++
build-aux/header-ifdef.pl | 182 ----------
build-aux/header-ifdef.py | 206 +++++++++++
build-aux/minimize-po.pl | 37 --
build-aux/minimize-po.py | 60 ++++
build-aux/mock-noinline.pl | 75 ----
build-aux/mock-noinline.py | 88 +++++
build-aux/prohibit-duplicate-header.pl | 26 --
build-aux/prohibit-duplicate-header.py | 54 +++
cfg.mk | 32 +-
configure.ac | 8 +
docs/Makefile.am | 17 +-
docs/genaclperms.pl | 125 -------
docs/genaclperms.py | 122 +++++++
docs/hacking.html.in | 30 ++
docs/hvsupport.pl | 458 -----------------------
docs/hvsupport.py | 479 +++++++++++++++++++++++++
po/Makefile.am | 2 +-
src/Makefile.am | 156 +++-----
src/access/Makefile.inc.am | 6 +-
src/access/genpolkit.pl | 119 ------
src/access/genpolkit.py | 119 ++++++
src/bhyve/Makefile.inc.am | 4 +-
src/check-aclperms.pl | 73 ----
src/check-aclperms.py | 77 ++++
src/check-aclrules.pl | 252 -------------
src/check-aclrules.py | 244 +++++++++++++
src/check-driverimpls.pl | 80 -----
src/check-driverimpls.py | 96 +++++
src/check-drivername.pl | 83 -----
src/check-drivername.py | 112 ++++++
src/check-remote-protocol.py | 131 +++++++
src/check-symfile.pl | 70 ----
src/check-symfile.py | 80 +++++
src/check-symsorting.pl | 106 ------
src/check-symsorting.py | 112 ++++++
src/dtrace2systemtap.pl | 130 -------
src/dtrace2systemtap.py | 140 ++++++++
src/esx/Makefile.inc.am | 2 +-
src/hyperv/Makefile.inc.am | 2 +-
src/interface/Makefile.inc.am | 2 +-
src/libxl/Makefile.inc.am | 4 +-
src/locking/Makefile.inc.am | 6 +-
src/logging/Makefile.inc.am | 2 +-
src/lxc/Makefile.inc.am | 4 +-
src/network/Makefile.inc.am | 2 +-
src/node_device/Makefile.inc.am | 2 +-
src/nwfilter/Makefile.inc.am | 2 +-
src/qemu/Makefile.inc.am | 4 +-
src/remote/Makefile.inc.am | 4 +-
src/rpc/Makefile.inc.am | 2 +-
src/rpc/gensystemtap.pl | 193 ----------
src/rpc/gensystemtap.py | 174 +++++++++
src/secret/Makefile.inc.am | 2 +-
src/storage/Makefile.inc.am | 2 +-
src/util/Makefile.inc.am | 8 +-
src/vbox/Makefile.inc.am | 2 +-
src/vz/Makefile.inc.am | 2 +-
tests/Makefile.am | 4 +-
tests/check-file-access.pl | 126 -------
tests/check-file-access.py | 121 +++++++
tests/file_access_whitelist.txt | 2 +-
tests/group-qemu-caps.pl | 124 -------
tests/group-qemu-caps.py | 115 ++++++
tests/test-wrap-argv.pl | 174 ---------
tests/test-wrap-argv.py | 162 +++++++++
tests/testutils.c | 16 +-
71 files changed, 3132 insertions(+), 2872 deletions(-)
delete mode 100755 build-aux/augeas-gentest.pl
create mode 100755 build-aux/augeas-gentest.py
delete mode 100755 build-aux/check-spacing.pl
create mode 100755 build-aux/check-spacing.py
delete mode 100644 build-aux/header-ifdef.pl
create mode 100644 build-aux/header-ifdef.py
delete mode 100755 build-aux/minimize-po.pl
create mode 100755 build-aux/minimize-po.py
delete mode 100644 build-aux/mock-noinline.pl
create mode 100644 build-aux/mock-noinline.py
delete mode 100644 build-aux/prohibit-duplicate-header.pl
create mode 100644 build-aux/prohibit-duplicate-header.py
delete mode 100755 docs/genaclperms.pl
create mode 100755 docs/genaclperms.py
delete mode 100755 docs/hvsupport.pl
create mode 100755 docs/hvsupport.py
delete mode 100755 src/access/genpolkit.pl
create mode 100755 src/access/genpolkit.py
delete mode 100755 src/check-aclperms.pl
create mode 100755 src/check-aclperms.py
delete mode 100755 src/check-aclrules.pl
create mode 100755 src/check-aclrules.py
delete mode 100755 src/check-driverimpls.pl
create mode 100755 src/check-driverimpls.py
delete mode 100755 src/check-drivername.pl
create mode 100644 src/check-drivername.py
create mode 100644 src/check-remote-protocol.py
delete mode 100755 src/check-symfile.pl
create mode 100755 src/check-symfile.py
delete mode 100755 src/check-symsorting.pl
create mode 100755 src/check-symsorting.py
delete mode 100755 src/dtrace2systemtap.pl
create mode 100755 src/dtrace2systemtap.py
delete mode 100755 src/rpc/gensystemtap.pl
create mode 100755 src/rpc/gensystemtap.py
delete mode 100755 tests/check-file-access.pl
create mode 100755 tests/check-file-access.py
delete mode 100755 tests/group-qemu-caps.pl
create mode 100755 tests/group-qemu-caps.py
delete mode 100755 tests/test-wrap-argv.pl
create mode 100755 tests/test-wrap-argv.py
--
2.21.0
5 years
[libvirt] [PATCH] qemu_process: fix starting VMs if machine group has limited cpuset.cpus
by Pavel Hrdina
Commit <f136b83139c63f20de0df3285d9e82df2fb97bfc> reworked process
affinity setting but did not take cgroups into account which introduced
an issue when starting VM with custom cpuset.cpus for the whole machine
group.
If the machine group is limited to some pCPUs libvirt should not try to
set a VM to run on all pCPUs as it will result in permission denied when
writing to cpuset.cpus.
To fix this the affinity has to be set separately from cgroups cpuset.
Resolves: <https://bugzilla.redhat.com/show_bug.cgi?id=1746517>
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_process.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ed8666e9d1..355b740caf 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2636,6 +2636,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
virDomainNumatuneMemMode mem_mode;
virCgroupPtr cgroup = NULL;
virBitmapPtr use_cpumask = NULL;
+ virBitmapPtr afinity_cpumask = NULL;
g_autoptr(virBitmap) hostcpumap = NULL;
char *mem_mask = NULL;
int ret = -1;
@@ -2661,7 +2662,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
* its config file */
if (qemuProcessGetAllCpuAffinity(&hostcpumap) < 0)
goto cleanup;
- use_cpumask = hostcpumap;
+ afinity_cpumask = hostcpumap;
}
/*
@@ -2702,8 +2703,11 @@ qemuProcessSetupPid(virDomainObjPtr vm,
}
+ if (!afinity_cpumask)
+ afinity_cpumask = use_cpumask;
+
/* Setup legacy affinity. */
- if (use_cpumask && virProcessSetAffinity(pid, use_cpumask) < 0)
+ if (afinity_cpumask && virProcessSetAffinity(pid, afinity_cpumask) < 0)
goto cleanup;
/* Set scheduler type and priority, but not for the main thread. */
--
2.23.0
5 years
[libvirt] [PATCH v2] news: mention 'ramfb' mdev attribute
by Jonathon Jongsma
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
v2:
Made changes suggested by Andrea. I'll need somebody to push this for me ;)
docs/news.xml | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/docs/news.xml b/docs/news.xml
index c362bf3a15..240d288c37 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -53,6 +53,19 @@
which were introduced in QEMU 4.2.0.
</description>
</change>
+ <change>
+ <summary>
+ qemu: Support boot display for GPU mediated devices
+ </summary>
+ <description>
+ Until now, GPU mediated devices generally did not show any output
+ until the guest OS had initialized the vGPU. By specifying the
+ <code>ramfb</code> attribute, QEMU can be configured to use ramfb as
+ a boot display for the device: this allows for display of firmware
+ messages, boot loader menu, and other output before the guest OS has
+ initialized the vGPU.
+ </description>
+ </change>
</section>
<section title="Improvements">
</section>
--
2.21.0
5 years
[libvirt] [PATCH 0/2] Couple of virbpf related fixes
by Michal Privoznik
Both are trivial and fix a build issue on my 32bit machine so I've
pushed them already.
Michal Prívozník (2):
vircgroupv2devices: Fix format string for size_t variable
virbpf: Fix typecast to __aligned_u64 type
src/util/virbpf.c | 32 ++++++++++++++++----------------
src/util/vircgroupv2devices.c | 2 +-
2 files changed, 17 insertions(+), 17 deletions(-)
--
2.23.0
5 years
[libvirt] [PATCH] virbpf: Check if syscall() is available
by Michal Privoznik
There are some OSes which don't have syscall() nor
<sys/syscall.h>. We already check for the header file in
configure phase, so we just need to add check for
HAVE_SYS_SYSCALL_H to HAVE_DECL_BPF_PROG_QUERY.
While I'm at it, some header files we are including are not
needed, so their includes can be safely dropped.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under build breaker rule.
src/util/virbpf.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/util/virbpf.c b/src/util/virbpf.c
index cb5562540b..44f13fb485 100644
--- a/src/util/virbpf.c
+++ b/src/util/virbpf.c
@@ -17,22 +17,19 @@
*/
#include <config.h>
-#include <sys/syscall.h>
-
-#include "internal.h"
-
-#include "viralloc.h"
-#include "virbpf.h"
-#include "virerror.h"
-#include "virfile.h"
#include "virlog.h"
-#include "virstring.h"
+#include "virerror.h"
+#include "virbpf.h"
VIR_LOG_INIT("util.bpf");
#define VIR_FROM_THIS VIR_FROM_BPF
-#if HAVE_DECL_BPF_PROG_QUERY
+#if HAVE_SYS_SYSCALL_H && HAVE_DECL_BPF_PROG_QUERY
+# include <sys/syscall.h>
+# include <unistd.h>
+
+
int
virBPFCreateMap(unsigned int mapType,
unsigned int keySize,
@@ -294,7 +291,11 @@ virBPFDeleteElem(int mapfd,
return syscall(SYS_bpf, BPF_MAP_DELETE_ELEM, &attr, sizeof(attr));
}
-#else /* HAVE_DECL_BPF_PROG_QUERY */
+
+
+#else /* !HAVE_SYS_SYSCALL_H || !HAVE_DECL_BPF_PROG_QUERY */
+
+
int
virBPFCreateMap(unsigned int mapType G_GNUC_UNUSED,
unsigned int keySize G_GNUC_UNUSED,
@@ -433,4 +434,4 @@ virBPFDeleteElem(int mapfd G_GNUC_UNUSED,
_("BPF not supported with this kernel"));
return -1;
}
-#endif /* HAVE_DECL_BPF_PROG_QUERY */
+#endif /* !HAVE_SYS_SYSCALL_H || !HAVE_DECL_BPF_PROG_QUERY */
--
2.23.0
5 years