[libvirt] [PATCH 0/7] qemu: checkpoints: Collect most code in a single place
by Peter Krempa
The checkpoint code is quite complex and was dispersed in many places.
Refactor it to be in one new separate file.
I also plan to do the same to the snapshot code once this is dealt with.
Additionally aggregating all the code in one place will allow
refactoring and reuse in the incremental backup implementation.
Peter Krempa (7):
qemu: Move, rename and export qemuDomObjFromDomain
conf: Drop pointless 'domain' argument from
virDomainCheckpointRedefinePrep
conf: Drop pointless 'domain' argument from
virDomainSnapshotRedefinePrep
qemu: driver: Remove misplaced qemuDomainObjEndJob in
qemuDomainCheckpointGetXMLDesc
qemu: driver: Move checkpoint-related code to qemu_checkpoint.c
qemu: domain: Move checkpoint related code to qemu_checkpoint.c
qemu: driver: Don't pull in qemu_monitor_json.h directly
src/conf/checkpoint_conf.c | 7 +-
src/conf/checkpoint_conf.h | 3 +-
src/conf/snapshot_conf.c | 5 +-
src/conf/snapshot_conf.h | 3 +-
src/qemu/Makefile.inc.am | 2 +
src/qemu/qemu_checkpoint.c | 646 ++++++++++++++++++++++++++++++++++
src/qemu/qemu_checkpoint.h | 55 +++
src/qemu/qemu_domain.c | 193 ++---------
src/qemu/qemu_domain.h | 16 +-
src/qemu/qemu_driver.c | 686 ++++++++-----------------------------
src/test/test_driver.c | 4 +-
11 files changed, 887 insertions(+), 733 deletions(-)
create mode 100644 src/qemu/qemu_checkpoint.c
create mode 100644 src/qemu/qemu_checkpoint.h
--
2.21.0
5 years, 3 months
[libvirt] [PATCH python v2] Custom impl for virConnectSetIdentity which can't be generated
by Daniel P. Berrangé
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
generator.py | 1 +
libvirt-override-api.xml | 7 +++++
libvirt-override.c | 64 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+)
diff --git a/generator.py b/generator.py
index 433c1f2..913dab8 100755
--- a/generator.py
+++ b/generator.py
@@ -489,6 +489,7 @@ skip_impl = (
'virDomainGetDiskErrors',
'virNodeGetMemoryParameters',
'virNodeSetMemoryParameters',
+ 'virConnectSetIdentity',
'virNodeGetCPUMap',
'virDomainMigrate3',
'virDomainMigrateToURI3',
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index b2a6259..7a0d4c5 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -796,5 +796,12 @@
<arg name='types' type='int' info='optional binary-OR of virDomainGuestInfoTypes'/>
<arg name='flags' type='int' info='unused, always pass 0'/>
</function>
+ <function name='virConnectSetIdentity' file='libvirt-host' module='libvirt-host'>
+ <info>Override the default identity information associated with the connection.</info>
+ <return type='int' info='0 if the identity change was accepted, -1 on error'/>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ <arg name='params' type='virTypedParameterPtr' info='parameters containing the identity attributes'/>
+ <arg name='flags' type='unsigned int' info='currently unused, pass 0'/>
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index ff2cfdf..72edca9 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -10209,6 +10209,67 @@ libvirt_virDomainGetGuestInfo(PyObject *self ATTRIBUTE_UNUSED,
}
#endif /* LIBVIR_CHECK_VERSION(5, 7, 0) */
+
+#if LIBVIR_CHECK_VERSION(5, 8, 0)
+static virPyTypedParamsHint virPyConnectSetIdentityParams[] = {
+ { VIR_CONNECT_IDENTITY_USER_NAME, VIR_TYPED_PARAM_STRING },
+ { VIR_CONNECT_IDENTITY_UNIX_USER_ID, VIR_TYPED_PARAM_ULLONG },
+ { VIR_CONNECT_IDENTITY_GROUP_NAME, VIR_TYPED_PARAM_STRING },
+ { VIR_CONNECT_IDENTITY_UNIX_GROUP_ID, VIR_TYPED_PARAM_ULLONG },
+ { VIR_CONNECT_IDENTITY_PROCESS_ID, VIR_TYPED_PARAM_LLONG },
+ { VIR_CONNECT_IDENTITY_PROCESS_TIME, VIR_TYPED_PARAM_ULLONG },
+ { VIR_CONNECT_IDENTITY_SASL_USER_NAME, VIR_TYPED_PARAM_STRING },
+ { VIR_CONNECT_IDENTITY_X509_DISTINGUISHED_NAME, VIR_TYPED_PARAM_STRING },
+ { VIR_CONNECT_IDENTITY_SELINUX_CONTEXT, VIR_TYPED_PARAM_STRING },
+};
+
+static PyObject *
+libvirt_virConnectSetIdentity(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ virConnectPtr conn;
+ PyObject *pyobj_conn, *dict;
+ PyObject *ret = NULL;
+ int i_retval;
+ int nparams = 0;
+ unsigned int flags;
+ virTypedParameterPtr params = NULL;
+
+ if (!PyArg_ParseTuple(args,
+ (char *)"OOI:virConnectSetIdentity",
+ &pyobj_conn, &dict, &flags))
+ return NULL;
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ if (!PyDict_Check(dict)) {
+ PyErr_Format(PyExc_TypeError, "migration params must be a dictionary");
+ return NULL;
+ }
+
+ if (virPyDictToTypedParams(dict, ¶ms, &nparams,
+ virPyConnectSetIdentityParams,
+ VIR_N_ELEMENTS(virPyConnectSetIdentityParams)) < 0) {
+ return NULL;
+ }
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ i_retval = virConnectSetIdentity(conn, params, nparams, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (i_retval < 0) {
+ ret = VIR_PY_INT_FAIL;
+ goto cleanup;
+ }
+
+ ret = VIR_PY_INT_SUCCESS;
+
+ cleanup:
+ virTypedParamsFree(params, nparams);
+ return ret;
+}
+#endif /* LIBVIR_CHECK_VERSION(5, 8, 0) */
+
+
/************************************************************************
* *
* The registration stuff *
@@ -10467,6 +10528,9 @@ static PyMethodDef libvirtMethods[] = {
#if LIBVIR_CHECK_VERSION(5, 7, 0)
{(char *) "virDomainGetGuestInfo", libvirt_virDomainGetGuestInfo, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(5, 7, 0) */
+#if LIBVIR_CHECK_VERSION(5, 8, 0)
+ {(char *) "virConnectSetIdentity", libvirt_virConnectSetIdentity, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(5, 8, 0) */
{NULL, NULL, 0, NULL}
};
--
2.21.0
5 years, 3 months
[libvirt] [PATCH python] Custom impl for virConnectSetIdentity which can't be generated
by Daniel P. Berrangé
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
generator.py | 1 +
libvirt-override.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
diff --git a/generator.py b/generator.py
index 433c1f2..913dab8 100755
--- a/generator.py
+++ b/generator.py
@@ -489,6 +489,7 @@ skip_impl = (
'virDomainGetDiskErrors',
'virNodeGetMemoryParameters',
'virNodeSetMemoryParameters',
+ 'virConnectSetIdentity',
'virNodeGetCPUMap',
'virDomainMigrate3',
'virDomainMigrateToURI3',
diff --git a/libvirt-override.c b/libvirt-override.c
index ff2cfdf..33f20d1 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -10209,6 +10209,69 @@ libvirt_virDomainGetGuestInfo(PyObject *self ATTRIBUTE_UNUSED,
}
#endif /* LIBVIR_CHECK_VERSION(5, 7, 0) */
+
+#if LIBVIR_CHECK_VERSION(5, 8, 0)
+static virPyTypedParamsHint virPyConnectSetIdentityParams[] = {
+ { VIR_CONNECT_IDENTITY_USER_NAME, VIR_TYPED_PARAM_STRING },
+ { VIR_CONNECT_IDENTITY_UNIX_USER_ID, VIR_TYPED_PARAM_ULLONG },
+ { VIR_CONNECT_IDENTITY_GROUP_NAME, VIR_TYPED_PARAM_STRING },
+ { VIR_CONNECT_IDENTITY_UNIX_GROUP_ID, VIR_TYPED_PARAM_ULLONG },
+ { VIR_CONNECT_IDENTITY_PROCESS_ID, VIR_TYPED_PARAM_LLONG },
+ { VIR_CONNECT_IDENTITY_PROCESS_TIME, VIR_TYPED_PARAM_ULLONG },
+ { VIR_CONNECT_IDENTITY_SASL_USER_NAME, VIR_TYPED_PARAM_STRING },
+ { VIR_CONNECT_IDENTITY_X509_DISTINGUISHED_NAME, VIR_TYPED_PARAM_STRING },
+ { VIR_CONNECT_IDENTITY_SELINUX_CONTEXT, VIR_TYPED_PARAM_STRING },
+};
+
+static PyObject *
+libvirt_virConnectSetIdentity(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ virConnectPtr conn;
+ PyObject *pyobj_conn, *dict;
+ PyObject *ret = NULL;
+ int i_retval;
+ int nparams = 0;
+ Py_ssize_t size = 0;
+ unsigned int flags;
+ virTypedParameterPtr params = NULL, new_params = NULL;
+
+ if (!PyArg_ParseTuple(args,
+ (char *)"OOI:virConnectSetIdentity",
+ &pyobj_conn, &dict, &flags))
+ return NULL;
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ if (!PyDict_Check(dict)) {
+ PyErr_Format(PyExc_TypeError, "migration params must be a dictionary");
+ return NULL;
+ }
+
+ if (virPyDictToTypedParams(dict, ¶ms, &nparams,
+ virPyConnectSetIdentityParams,
+ VIR_N_ELEMENTS(virPyConnectSetIdentityParams)) < 0) {
+ return NULL;
+ }
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ i_retval = virConnectSetIdentity(conn, new_params, size, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (i_retval < 0) {
+ ret = VIR_PY_INT_FAIL;
+ goto cleanup;
+ }
+
+ ret = VIR_PY_INT_SUCCESS;
+
+ cleanup:
+ virTypedParamsFree(params, nparams);
+ virTypedParamsFree(new_params, size);
+ return ret;
+}
+#endif /* LIBVIR_CHECK_VERSION(5, 8, 0) */
+
+
/************************************************************************
* *
* The registration stuff *
@@ -10467,6 +10530,9 @@ static PyMethodDef libvirtMethods[] = {
#if LIBVIR_CHECK_VERSION(5, 7, 0)
{(char *) "virDomainGetGuestInfo", libvirt_virDomainGetGuestInfo, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(5, 7, 0) */
+#if LIBVIR_CHECK_VERSION(5, 8, 0)
+ {(char *) "virConnectSetIdentity", libvirt_virConnectSetIdentity, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(5, 8, 0) */
{NULL, NULL, 0, NULL}
};
--
2.21.0
5 years, 3 months
[libvirt] [PATCH 0/2] libvirt-rust: Fixing bugs in Stream::{send, recv}
by Linus Färnstrand
Hi,
Fixing memory soundness bugs in Stream::recv, and other bugs in both
Stream::recv and Stream::send.
The method Stream::recv takes a size argument that it passes on as the nbytes
argument to virStreamRecv. The problem is that the corresponding data pointer
points to a local stack allocated array with a fixed size of 2048. So calling
Stream::recv with a size larger than 2048 can cause virStreamRecv to write
past the given buffer!
The library calls CStr::from_ptr(data) on the locally allocated buffer after
virStreamRecv returns. CStr::from_ptr will scan the memory from the given
pointer for the terminating null byte. There is no guarantee this buffer will
properly end with a null byte. The buffer is initialized with only nulls.
But since virStreamRecv can overwrite the entire buffer (and beyond!), there
is no guarantee there will be a null byte in the buffer at this point. As a
result, CStr::from_ptr can continue to read past the buffer. This can cause
either reading invalid memory, or it can cause the method to return a string
containing data from the stack way past the data written by virStreamRecv.
Heartbleed style issue.
The code does not check for the -2 error code in the return value of
virStreamRecv, treating it as a success. It looks like it will make it just
return an empty string as result. But a bug nonetheless.
After parsing the buffer as a C string in Stream::recv, it is lossily converted
into a Rust UTF-8 string with CStr::to_string_lossy. It can cause the data to
be modified before it is returned to the caller.
U+FFFD REPLACEMENT CHARACTER will be inserted on invalid UTF-8 codepoints.
The FFI bindings for both virStreamRecv and virStreamSend are wrong. They
specify the nbytes argument as c_int instead of size_t as the C library does.
I don't have access to SMTP on my dev machine. Hope ProtonMail does not
reformat this.
Have a great day
Linus Färnstrand
Linus Färnstrand (2):
Fix bugs in Stream::recv
Fix Stream::send
src/stream.rs | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
--
2.21.0
5 years, 3 months
[libvirt] [PATCH 0/8] qemu: monitor: Clean up some more HMP cruft
by Peter Krempa
There was quite a bit of legacy HMP cruft. We can remove it as we use
HMP commands via QMP.
Peter Krempa (8):
qemu: monitor: Remove legacy monitor commands for FD manipulation
qemu: monitor: Remove qemuMonitorHMPCommand macro
qemu: monitor: Remove support for HMP commands with fds
qemu: monitor: Don't escape HMP commands just to unescape them right
away
qemu: monitor: Remove HMP command (un)escaping infrastructure
qemu: monitor: Don't include text monitor in json monitor
qemu: monitor: Don't handle HMP in qemuMonitorJSONArbitraryCommand
qemu: monitor: Remove qemuMonitorHMPCommand in favor of
qemuMonitorJSONHumanCommand
src/qemu/qemu_monitor.c | 178 +----------------------------------
src/qemu/qemu_monitor.h | 13 +--
src/qemu/qemu_monitor_json.c | 104 +++-----------------
src/qemu/qemu_monitor_json.h | 13 +--
src/qemu/qemu_monitor_text.c | 39 +++-----
tests/qemumonitortestutils.c | 6 +-
6 files changed, 32 insertions(+), 321 deletions(-)
--
2.21.0
5 years, 3 months
[libvirt] [PATCH] qemu_conf: clear domain before VIR_DELETE_ELEMENT
by Xu Yandong
The macro VIR_DELETE_ELEMENT assume that the items being deleted have
already been cleared, so we must explicitly delete domain memory to
prevent a memory leak.
Signed-off-by: Xu Yandong <xuyandong2(a)huawei.com>
---
src/qemu/qemu_conf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 1aeec30f8a..db390d358e 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1620,10 +1620,12 @@ qemuSharedDeviceEntryRemove(virQEMUDriverPtr driver,
if (!qemuSharedDeviceEntryDomainExists(entry, name, &idx))
return 0;
- if (entry->ref != 1)
+ if (entry->ref != 1) {
+ VIR_FREE(entry->domains[idx]);
VIR_DELETE_ELEMENT(entry->domains, idx, entry->ref);
- else
+ } else {
ignore_value(virHashRemoveEntry(driver->sharedDevices, key));
+ }
return 0;
}
--
2.18.1
5 years, 3 months
[libvirt] [PATCH] event: reference state only when virEventAddTimeout success
by Xu Yandong
Reference state is not necessary when virEventAddTimeout failed,
this may cause a memory leak, so reference state only when
virEventAddTimeout success.
Signed-off-by: Xu Yandong <xuyandong2(a)huawei.com>
---
src/conf/object_event.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/conf/object_event.c b/src/conf/object_event.c
index 5d84598d59..ee5def5910 100644
--- a/src/conf/object_event.c
+++ b/src/conf/object_event.c
@@ -891,20 +891,21 @@ virObjectEventStateRegisterID(virConnectPtr conn,
virObjectLock(state);
if ((state->callbacks->count == 0) &&
- (state->timer == -1) &&
- (state->timer = virEventAddTimeout(-1,
- virObjectEventTimer,
- state,
- virObjectFreeCallback)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("could not initialize domain event timer"));
- goto cleanup;
+ (state->timer == -1)) {
+ if ((state->timer = virEventAddTimeout(-1,
+ virObjectEventTimer,
+ state,
+ virObjectFreeCallback)) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("could not initialize domain event timer"));
+ goto cleanup;
+ } else {
+ /* event loop has one reference, but we need one more for the
+ * timer's opaque argument */
+ virObjectRef(state);
+ }
}
- /* event loop has one reference, but we need one more for the
- * timer's opaque argument */
- virObjectRef(state);
-
ret = virObjectEventCallbackListAddID(conn, state->callbacks,
key, filter, filter_opaque,
klass, eventID,
--
2.18.1
5 years, 3 months
[libvirt] [PATCH] qemu: fix Validate scsi disk against domain def on coldplug
by Xu Yandong
Check the disk scsi address only when the disk is scsi type.
Signed-off-by: Xu Yandong <xuyandong2(a)huawei.com>
---
src/qemu/qemu_driver.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 62ce7270ca..ff2173da5e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8326,7 +8326,8 @@ static int
qemuCheckDiskConfigAgainstDomain(const virDomainDef *def,
const virDomainDiskDef *disk)
{
- if (virDomainSCSIDriveAddressIsUsed(def, &disk->info.addr.drive)) {
+ if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI &&
+ virDomainSCSIDriveAddressIsUsed(def, &disk->info.addr.drive)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Domain already contains a disk with that address"));
return -1;
--
2.18.1
5 years, 3 months
[libvirt] [PATCH] gnulib: remove unused secure_getenv function replacement
by Daniel P. Berrangé
We removed use of the secure_getenv recently in
commit 2b0d597670fb5504b7ad1411c31b8af1d3016c1b
Author: Daniel P. Berrangé <berrange(a)redhat.com>
Date: Thu Aug 1 13:35:56 2019 +0100
util: get rid of virGetEnv{Allow,Block}SUID functions
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
bootstrap.conf | 1 -
1 file changed, 1 deletion(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index a833a396c0..1ddc2a0305 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -89,7 +89,6 @@ pthread_sigmask
recv
regex
sched
-secure_getenv
send
setenv
setsockopt
--
2.21.0
5 years, 3 months