[libvirt] [ocaml PATCH 0/4] Minor cleanups/fixes
by Pino Toscano
Small cleanups in the build system, no changes in the code/binding.
Pino Toscano (4):
build: stop generating a config.h
build: drop broken NSIS leftovers
build: remove manual OCaml dependencies
build: remove the list_secrets binary on clean
.gitignore | 2 --
MANIFEST | 1 -
Makefile.in | 26 ++------------------------
configure.ac | 1 -
libvirt/Makefile.in | 6 ------
libvirt/generator.pl | 2 --
6 files changed, 2 insertions(+), 36 deletions(-)
--
2.21.0
5 years, 7 months
[libvirt] [PATCH] qemu: extract function qemuDomainDefIsUEFI()
by Jonathon Jongsma
Rather than repeating the conditions in a couple places, extract it into
a separate function for detecting whether a domain definition uses UEFI.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
As requested by Andrea, I've extracted this little bit of refactoring from my
bochs display patch and am sending it separately.
src/qemu/qemu_domain.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4998474dc9..ed4b5c666d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4584,6 +4584,14 @@ qemuDomainValidateCpuCount(const virDomainDef *def,
}
+static bool
+qemuDomainDefIsUEFI(const virDomainDef *def)
+{
+ return ((def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI ||
+ (def->os.loader && def->os.loader->type ==
+ VIR_DOMAIN_LOADER_TYPE_PFLASH)));
+}
+
static int
qemuDomainDefValidate(const virDomainDef *def,
virCapsPtr caps ATTRIBUTE_UNUSED,
@@ -4606,10 +4614,7 @@ qemuDomainDefValidate(const virDomainDef *def,
}
/* On x86, UEFI requires ACPI */
- if ((def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI ||
- (def->os.loader &&
- def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH)) &&
- ARCH_IS_X86(def->os.arch) &&
+ if (qemuDomainDefIsUEFI(def) && ARCH_IS_X86(def->os.arch) &&
def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("UEFI requires ACPI on this architecture"));
@@ -4619,9 +4624,7 @@ qemuDomainDefValidate(const virDomainDef *def,
/* On aarch64, ACPI requires UEFI */
if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON &&
def->os.arch == VIR_ARCH_AARCH64 &&
- (def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_EFI &&
- (!def->os.loader ||
- def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH))) {
+ !qemuDomainDefIsUEFI(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("ACPI requires UEFI on this architecture"));
goto cleanup;
--
2.21.0
5 years, 7 months
[libvirt] [PATCH REPOST] Revert "lxc: Try harder to stop/reboot containers"
by Daniel P. Berrangé
This reverts commit 14b6a1854fb4c02c5fb2f51679f8ff099f28f53c.
If virLXCDomainSetRunlevel returns -1 this indicates a serious
error / failure that must be propagated to the caller. We must
not carry on with other shutdown methods in this case.
If virLXCDomainSetRunlevel return 0, this indicates that no
initctl was found and it is thus reasonable to fallback to
sending SIGTERM.
The commit being reverted is broken because it would fallback
to SIGTERM when virLXCDomainSetRunlevel returns -1, and would
not fallback when virLXCDomainSetRunlevel returns 0. ie it
did the exact opposite of what was required.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/lxc/lxc_driver.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 5453f49064..ca0090de59 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -3271,7 +3271,7 @@ lxcDomainShutdownFlags(virDomainPtr dom,
virLXCDomainObjPrivatePtr priv;
virDomainObjPtr vm;
int ret = -1;
- int rc = -1;
+ int rc;
virCheckFlags(VIR_DOMAIN_SHUTDOWN_INITCTL |
VIR_DOMAIN_SHUTDOWN_SIGNAL, -1);
@@ -3300,17 +3300,19 @@ lxcDomainShutdownFlags(virDomainPtr dom,
(flags & VIR_DOMAIN_SHUTDOWN_INITCTL)) {
int command = VIR_INITCTL_RUNLEVEL_POWEROFF;
- if ((rc = virLXCDomainSetRunlevel(vm, command)) < 0) {
- if (flags != 0 &&
- (flags & VIR_DOMAIN_SHUTDOWN_INITCTL)) {
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("Container does not provide an initctl pipe"));
- goto endjob;
- }
+ if ((rc = virLXCDomainSetRunlevel(vm, command)) < 0)
+ goto endjob;
+ if (rc == 0 && flags != 0 &&
+ ((flags & ~VIR_DOMAIN_SHUTDOWN_INITCTL) == 0)) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("Container does not provide an initctl pipe"));
+ goto endjob;
}
+ } else {
+ rc = 0;
}
- if (rc < 0 &&
+ if (rc == 0 &&
(flags == 0 ||
(flags & VIR_DOMAIN_SHUTDOWN_SIGNAL))) {
if (kill(priv->initpid, SIGTERM) < 0 &&
@@ -3347,7 +3349,7 @@ lxcDomainReboot(virDomainPtr dom,
virLXCDomainObjPrivatePtr priv;
virDomainObjPtr vm;
int ret = -1;
- int rc = -1;
+ int rc;
virCheckFlags(VIR_DOMAIN_REBOOT_INITCTL |
VIR_DOMAIN_REBOOT_SIGNAL, -1);
@@ -3376,17 +3378,19 @@ lxcDomainReboot(virDomainPtr dom,
(flags & VIR_DOMAIN_REBOOT_INITCTL)) {
int command = VIR_INITCTL_RUNLEVEL_REBOOT;
- if ((rc = virLXCDomainSetRunlevel(vm, command)) < 0) {
- if (flags != 0 &&
- (flags & VIR_DOMAIN_REBOOT_INITCTL)) {
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("Container does not provide an initctl pipe"));
- goto endjob;
- }
+ if ((rc = virLXCDomainSetRunlevel(vm, command)) < 0)
+ goto endjob;
+ if (rc == 0 && flags != 0 &&
+ ((flags & ~VIR_DOMAIN_SHUTDOWN_INITCTL) == 0)) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("Container does not provide an initctl pipe"));
+ goto endjob;
}
+ } else {
+ rc = 0;
}
- if (rc < 0 &&
+ if (rc == 0 &&
(flags == 0 ||
(flags & VIR_DOMAIN_REBOOT_SIGNAL))) {
if (kill(priv->initpid, SIGHUP) < 0 &&
--
2.21.0
5 years, 7 months
[libvirt] [PATCH] qemu: agent: fix potential leak in qemuAgentGetFSInfo()
by Jonathon Jongsma
On error paths, info_ret could potentially leak. Make sure it's freed.
---
Thanks to John Ferlan for the catch. Apparently this got missed before the
patch was merged
src/qemu/qemu_agent.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index c63db968c6..a4113460bd 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2208,6 +2208,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon,
virDomainFSInfoFree(info_ret[i]);
}
VIR_FREE(agentinfo);
+ VIR_FREE(info_ret);
return ret;
}
--
2.21.0
5 years, 7 months
[libvirt] [PATCH v2 0/9] qemu: Blockdevize external snapshot creation (blokcdev-add saga)
by Peter Krempa
Patches 1-5 of the original series were already pushed.
Patches 1-3 of this series are new and deal with fixing of a image
locking bug which was added during the blockdev-add saga as we've
changed the handling of the 'readonly' flag of an image.
Patch 4 is new and should solve review feedback which complained about
function naming.
The rest of the series is almost exactly as in previous posting with
following exceptions:
1) Review feedback incorporated and R-b's applied.
2) Patch 6/9 has a different summary
3) Patch 8/9 fixes a memory leak/crash as a part of the cleanup was
misplaced out of the cleaning loop (while still using the 'i' to
dereference arrays).
4) Conflicts with 4/9 resolved.
Peter Krempa (9):
qemu: snapshot: Fix image lock handling when taking a snapshot
qemu: snapshot: Save status and config XMLs only on success
qemu: snapshot: Move error preservation to
qemuDomainSnapshotDiskDataCleanup
qemu: snapshot: Rename external disk snapshot handling functions
qemu: Disband qemuDomainSnapshotCreateSingleDiskActive
qemu: Merge use of 'reuse' flag in qemuDomainSnapshotDiskPrepareOne
qemu: snapshot: Skip overlay file creation/interogation if unsupported
qemu: Add -blockdev support for external snapshots
qemu: Defer support checks for external active snapshots to blockdev
code or qemu
src/qemu/qemu_driver.c | 276 +++++++++++++++++++++++++----------------
1 file changed, 171 insertions(+), 105 deletions(-)
--
2.21.0
5 years, 7 months
[libvirt] [PATCH 0/2] [for-5.7.0] qemu: Honor qemu's request to use all vCPU props
by Peter Krempa
qemu documents that we should pass in all fields of
'CpuInstanceProperties' back when hotplugging cpus, but we didn't do
that. It turns out that qemu wanted to add new fields which were
mandatory and thus broke the interop with libvirt.
Let's honor their reques.
Peter Krempa (2):
qemu: Extract and store vCPU properties as qemu returned them
qemu: command: Use all vCPU properties when creating args for vCPU
hotplug
src/qemu/qemu_command.c | 19 +++----------------
src/qemu/qemu_domain.c | 3 +++
src/qemu/qemu_domain.h | 3 +++
src/qemu/qemu_monitor.c | 2 ++
src/qemu/qemu_monitor.h | 6 ++++++
src/qemu/qemu_monitor_json.c | 4 ++++
.../x86-modern-bulk-monitor.json | 8 ++++----
.../x86-modern-individual-add-monitor.json | 4 ++--
8 files changed, 27 insertions(+), 22 deletions(-)
--
2.21.0
5 years, 7 months
[libvirt] [PATCH 1/1] security_util: verify xattrs only if ref is present
by Nikolay Shirokovskiy
After 7cfb7aab573 commit starting a domain pullutes logs with
warnings like [1]. The reason is resource files do not
have timestamp before starting a domain and after destroying
domain the timestamp is cleared. Let's check the timestamp
only if attribute with refcounter is found.
[1] warning : virSecurityValidateTimestamp:198 : Invalid XATTR timestamp detected on \
/some/path secdriver=dac
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/security/security_util.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/security/security_util.c b/src/security/security_util.c
index 31f41cedfd..f33fe9dd7b 100644
--- a/src/security/security_util.c
+++ b/src/security/security_util.c
@@ -269,13 +269,9 @@ virSecurityGetRememberedLabel(const char *name,
VIR_AUTOFREE(char *) attr_name = NULL;
VIR_AUTOFREE(char *) value = NULL;
unsigned int refcount = 0;
- int rc;
*label = NULL;
- if ((rc = virSecurityValidateTimestamp(name, path)) < 0)
- return rc;
-
if (!(ref_name = virSecurityGetRefCountAttrName(name)))
return -1;
@@ -288,6 +284,14 @@ virSecurityGetRememberedLabel(const char *name,
ref_name,
path);
return -1;
+ } else {
+ int rc;
+
+ if ((rc = virSecurityValidateTimestamp(name, path)) < 0)
+ return rc;
+
+ if (rc == 1)
+ return -2;
}
if (virStrToLong_ui(value, NULL, 10, &refcount) < 0) {
@@ -357,10 +361,6 @@ virSecuritySetRememberedLabel(const char *name,
VIR_AUTOFREE(char *) attr_name = NULL;
VIR_AUTOFREE(char *) value = NULL;
unsigned int refcount = 0;
- int rc;
-
- if ((rc = virSecurityValidateTimestamp(name, path)) < 0)
- return rc;
if (!(ref_name = virSecurityGetRefCountAttrName(name)))
return -1;
@@ -375,6 +375,14 @@ virSecuritySetRememberedLabel(const char *name,
path);
return -1;
}
+ } else {
+ int rc;
+
+ if ((rc = virSecurityValidateTimestamp(name, path)) < 0)
+ return rc;
+
+ if (rc == 1)
+ VIR_FREE(value);
}
if (value &&
--
2.23.0
5 years, 7 months
[libvirt] [PATCH] util: activate directory override when used from library
by Daniel P. Berrangé
The Perl bindings for libvirt use the test driver for unit tests. This
tries to load the cpu_map/index.xml file, and when run from an
uninstalled build will fail.
The problem is that virFileActivateDirOverride is called by our various
binaries like libvirtd, virsh, but is not called when a 3rd party app
uses libvirt.so
To deal with this we allow the LIBVIRT_DIR_OVERRIDE=1 env variable to be
set and make virInitialize look for this. The 'run' script will set it,
so now build using this script to run against an uninstalled tree we
will correctly resolve files to the source tree.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
run.in | 3 +++
src/libvirt.c | 2 ++
src/util/virfile.c | 21 +++++++++++++--------
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/run.in b/run.in
index 9a1c6ea11a..de7af78f67 100644
--- a/run.in
+++ b/run.in
@@ -60,6 +60,9 @@ else
fi
export PKG_CONFIG_PATH
+LIBVIRT_DIR_OVERRIDE=1
+export LIBVIRT_DIR_OVERRIDE
+
# This is a cheap way to find some use-after-free and uninitialized
# read problems when using glibc.
random_val="$(awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)"
diff --git a/src/libvirt.c b/src/libvirt.c
index 956ccdea30..6b1b4a54c3 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -250,6 +250,8 @@ virGlobalInit(void)
virErrorInitialize() < 0)
goto error;
+ virFileActivateDirOverride(NULL);
+
if (getuid() != geteuid() ||
getgid() != getegid()) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 81a3c096eb..391b6a9e6e 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1776,14 +1776,19 @@ virFileFindResource(const char *filename,
void
virFileActivateDirOverride(const char *argv0)
{
- char *file = strrchr(argv0, '/');
- if (!file || file[1] == '\0')
- return;
- file++;
- if (STRPREFIX(file, "lt-") ||
- strstr(argv0, "/.libs/")) {
- useDirOverride = true;
- VIR_DEBUG("Activating build dir override for %s", argv0);
+ if (argv0 == NULL) {
+ if (getenv("LIBVIRT_DIR_OVERRIDE") != NULL)
+ useDirOverride = true;
+ } else {
+ char *file = strrchr(argv0, '/');
+ if (!file || file[1] == '\0')
+ return;
+ file++;
+ if (STRPREFIX(file, "lt-") ||
+ strstr(argv0, "/.libs/")) {
+ useDirOverride = true;
+ VIR_DEBUG("Activating build dir override for %s", argv0);
+ }
}
}
--
2.21.0
5 years, 7 months
[libvirt] [python PATCH] Implement virDomainGetGuestInfo
by Michal Privoznik
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
generator.py | 1 +
libvirt-override-api.xml | 7 +++++++
libvirt-override.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+)
diff --git a/generator.py b/generator.py
index 8922f93..0b0a5a7 100755
--- a/generator.py
+++ b/generator.py
@@ -507,6 +507,7 @@ skip_impl = (
'virNodeGetSEVInfo',
'virNetworkPortGetParameters',
'virNetworkPortSetParameters',
+ 'virDomainGetGuestInfo',
)
lxc_skip_impl = (
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 9c4d71d..b2a6259 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -789,5 +789,12 @@
<arg name='port' type='virNetworkPortPtr' info='pointer to network port object'/>
<arg name='flags' type='int' info='unused, always pass 0'/>
</function>
+ <function name='virDomainGetGuestInfo' file='python'>
+ <info>Get aggregated info from guest agent</info>
+ <return type='char *' info='None in case of error, returns a dictionary of params'/>
+ <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
+ <arg name='types' type='int' info='optional binary-OR of virDomainGuestInfoTypes'/>
+ <arg name='flags' type='int' info='unused, always pass 0'/>
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index 42f8198..5567f4a 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -10176,6 +10176,39 @@ libvirt_virNetworkPortGetParameters(PyObject *self ATTRIBUTE_UNUSED,
}
#endif /* LIBVIR_CHECK_VERSION(5, 5, 0) */
+#if LIBVIR_CHECK_VERSION(5, 7, 0)
+static PyObject *
+libvirt_virDomainGetGuestInfo(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ PyObject *pyobj_dom = NULL;
+ PyObject *dict = NULL;
+ virDomainPtr dom = NULL;
+ virTypedParameterPtr params = NULL;
+ int nparams = 0;
+ unsigned int types;
+ unsigned int flags;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, (char *) "OII:virDomainGetGuestInfo",
+ &pyobj_dom, &types, &flags))
+ return NULL;
+ dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ rc = virDomainGetGuestInfo(dom, types, ¶ms, &nparams, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (rc < 0)
+ return VIR_PY_NONE;
+
+ dict = getPyVirTypedParameter(params, nparams);
+
+ virTypedParamsFree(params, nparams);
+ return dict;
+}
+#endif /* LIBVIR_CHECK_VERSION(5, 7, 0) */
+
/************************************************************************
* *
* The registration stuff *
@@ -10431,6 +10464,9 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virNetworkPortSetParameters", libvirt_virNetworkPortSetParameters, METH_VARARGS, NULL},
{(char *) "virNetworkPortGetParameters", libvirt_virNetworkPortGetParameters, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(5, 5, 0) */
+#if LIBVIR_CHECK_VERSION(5, 7, 0)
+ {(char *) "virDomainGetGuestInfo", libvirt_virDomainGetGuestInfo, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(5, 7, 0) */
{NULL, NULL, 0, NULL}
};
--
2.21.0
5 years, 7 months