[libvirt PATCH 0/2] Fix bonehead errors in <hostdev> <teaming> support
by Laine Stump
I hadn't caught the code omission because my migration tester system
was out of commission, and I stupidly assumed migration would
work. The docs typo was pure lack of attention.
This (sub) feature will be new for this release, and there is an open
BZ for it downstream, so it would be nice to get the fix ACKed and
pushed in time for the release.
Laine Stump (2):
qemu: allow migration of generic <hostdev> with <teaming>
docs: fix bad cut/paste in <teaming> example
docs/formatdomain.rst | 3 +--
src/qemu/qemu_migration.c | 16 ++++++++++------
2 files changed, 11 insertions(+), 8 deletions(-)
--
2.29.2
3 years, 10 months
[PATCH] qemuMonitorUnregister: Fix use-after-free of mon->watch
by Peng Liang
qemuMonitorUnregister will be called in multiple threads (e.g. threads
in rpc worker pool and the vm event thread). In some cases, it isn't
protected by the monitor lock, which may lead to call g_source_unref
more than one time and a use-after-free problem eventually.
To avoid similar problem in the future, use
g_atomic_pointer_compare_and_exchange instead of adding a lock in the
missing cases.
Signed-off-by: Peng Liang <liangpeng10(a)huawei.com>
---
src/qemu/qemu_monitor.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 0476d606f553..f4d05cd951c2 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -853,10 +853,11 @@ qemuMonitorRegister(qemuMonitorPtr mon)
void
qemuMonitorUnregister(qemuMonitorPtr mon)
{
- if (mon->watch) {
- g_source_destroy(mon->watch);
- g_source_unref(mon->watch);
- mon->watch = NULL;
+ GSource *watch = mon->watch;
+
+ if (watch && g_atomic_pointer_compare_and_exchange(&mon->watch, watch, NULL)) {
+ g_source_destroy(watch);
+ g_source_unref(watch);
}
}
--
2.29.2
3 years, 10 months
[PATCH v2 3/4] utils: Deprecate hex-with-suffix sizes
by Eric Blake
Supporting '0x20M' looks odd, particularly since we have a 'B' suffix
that is ambiguous for bytes, as well as a less-frequently-used 'E'
suffix for extremely large exibytes. In practice, people using hex
inputs are specifying values in bytes (and would have written
0x2000000, or possibly relied on default_suffix in the case of
qemu_strtosz_MiB), and the use of scaling suffixes makes the most
sense for inputs in decimal (where the user would write 32M). But
rather than outright dropping support for hex-with-suffix, let's
follow our deprecation policy. Sadly, since qemu_strtosz() does not
have an Err** parameter, and plumbing that in would be a much larger
task, we instead go with just directly emitting the deprecation
warning to stderr.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
docs/system/deprecated.rst | 8 ++++++++
util/cutils.c | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 2fcac7861e07..113c2e933f1b 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -146,6 +146,14 @@ library enabled as a cryptography provider.
Neither the ``nettle`` library, or the built-in cryptography provider are
supported on FIPS enabled hosts.
+hexadecimal sizes with scaling multipliers (since 6.0)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+Input parameters that take a size value should only use a size suffix
+(such as 'k' or 'M') when the base is written in decimal, and not when
+the value is hexadecimal. That is, '0x20M' is deprecated, and should
+be written either as '32M' or as '0x2000000'.
+
QEMU Machine Protocol (QMP) commands
------------------------------------
diff --git a/util/cutils.c b/util/cutils.c
index 22d27b0fd21b..6a8a175e0d71 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -250,6 +250,9 @@ static int64_t suffix_mul(char suffix, int64_t unit)
* fractional portion is truncated to byte
* - 0x7fEE - hexadecimal, unit determined by @default_suffix
*
+ * The following cause a deprecation warning, and may be removed in the future
+ * - 0xabc{kKmMgGtTpP} - hex with scaling suffix
+ *
* The following are intentionally not supported
* - octal, such as 08
* - fractional hex, such as 0x1.8
@@ -272,7 +275,7 @@ static int do_strtosz(const char *nptr, const char **end,
int retval;
const char *endptr, *f;
unsigned char c;
- bool mul_required = false;
+ bool mul_required = false, hex = false;
uint64_t val;
int64_t mul;
double fraction = 0.0;
@@ -298,6 +301,7 @@ static int do_strtosz(const char *nptr, const char **end,
retval = -EINVAL;
goto out;
}
+ hex = true;
} else if (*endptr == '.') {
/*
* Input looks like a fraction. Make sure even 1.k works
@@ -320,6 +324,10 @@ static int do_strtosz(const char *nptr, const char **end,
c = *endptr;
mul = suffix_mul(c, unit);
if (mul > 0) {
+ if (hex) {
+ warn_report("Using a multiplier suffix on hex numbers "
+ "is deprecated: %s", nptr);
+ }
endptr++;
} else {
mul = suffix_mul(default_suffix, unit);
--
2.30.1
3 years, 10 months
[PATCH] libxl: Add lock process indicator to libxlDomainObjPrivate object
by Jim Fehlig
The libvirt libxl driver has no access to FDs associated with VM disks.
The disks are opened by libxl.so and any related FDs are not exposed to
applications. The prevents using virtlockd's auto-release feature to
release locks when the FD is closed. Acquiring and releasing locks is
explicitly handled by the libxl driver.
The current logic is structured such that locks are acquired in
libxlDomainStart and released in libxlDomainCleanup. This works well
except for migration, where the locks must be released on the source
host before the domain can be started on the destination host, but the
domain cannot be cleaned up until the migration confirmation stage.
When libxlDomainCleanup if finally called in the confirm stage, locks
are again released resulting in confusing errors from virtlockd and
libvirtd
virtlockd[8095]: resource busy: Lockspace resource 'xxxxxx' is not locked
libvirtd[8050]: resource busy: Lockspace resource 'xxxxxx' is not locked
libvirtd[8050]: Unable to release lease on testvm
The error is also encountered in some error cases, e.g. when
libxlDomainStart fails before acquiring locks and libxlDomainCleanup
is still used for cleanup.
In lieu of a mechanism to check if a lock has been acquired, this patch
takes an easy approach to fixing the unnecessary lock releases by adding
an indicator to the libxlDomainPrivate object that can be set when the
lock is acquired and cleared when the lock is released. libxlDomainCleanup
can then skip releasing the lock in cases where it was previously released
or never acquired in the first place.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
danpb and I discussed this issue on IRC and after pursuing several options
I've decided to send this simple approach to the list for comment. I reworked
the code in several ways but in the end cant escape the fact that there are
occasions where domain cleanup needs to be performed but stopping the lock
process is not needed. Another simple approach I pursued was creating a
cleanup function that skipped virDomainLockProcessPause, but this approach
was a bit cleaner IMO. Other suggestions welcomed.
All is not lost in the effort as it resulted in several cleanup and
improvement patches that I'll post after release. It includes decomposing
libxlDomainStart and making it idempotent on error so libxlDomainCleanup
only needs to be called after a successful call to libxlDomainStart.
src/libxl/libxl_domain.c | 13 +++++++++----
src/libxl/libxl_domain.h | 1 +
src/libxl/libxl_migration.c | 8 ++++++--
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 604b94a006..014f6aceca 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -861,10 +861,14 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
virHostdevReAttachDomainDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
vm->def, hostdev_flags);
- VIR_FREE(priv->lockState);
- if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
- VIR_WARN("Unable to release lease on %s", vm->def->name);
- VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
+ if (priv->lockProcessRunning) {
+ VIR_FREE(priv->lockState);
+ if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
+ VIR_WARN("Unable to release lease on %s", vm->def->name);
+ else
+ priv->lockProcessRunning = false;
+ VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
+ }
libxlLoggerCloseFile(cfg->logger, vm->def->id);
vm->def->id = -1;
@@ -1426,6 +1430,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
priv->lockState) < 0)
goto destroy_dom;
VIR_FREE(priv->lockState);
+ priv->lockProcessRunning = true;
/* Always enable domain death events */
if (libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->deathW))
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 00682546e0..5fb76bd303 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -68,6 +68,7 @@ struct _libxlDomainObjPrivate {
virThreadPtr migrationDstReceiveThr;
unsigned short migrationPort;
char *lockState;
+ bool lockProcessRunning;
struct libxlDomainJobObj job;
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 631f67930d..a5a9df98ad 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -1242,9 +1242,12 @@ libxlDomainMigrationSrcPerform(libxlDriverPrivatePtr driver,
virObjectLock(vm);
if (ret == 0) {
- if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
+ if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) == 0) {
+ priv->lockProcessRunning = false;
+ VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
+ } else {
VIR_WARN("Unable to release lease on %s", vm->def->name);
- VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
+ }
} else {
/*
* Confirm phase will not be executed if perform fails. End the
@@ -1377,6 +1380,7 @@ libxlDomainMigrationSrcConfirm(libxlDriverPrivatePtr driver,
"xen:///system",
vm,
priv->lockState);
+ priv->lockProcessRunning = true;
if (libxl_domain_resume(cfg->ctx, vm->def->id, 1, 0) == 0) {
ret = 0;
} else {
--
2.29.2
3 years, 10 months
A brief look at deprecating our JSON extensions over RFC 8259
by Markus Armbruster
We use JSON in several external interfaces:
* QMP
* The guest agent's QMP
* QAPIfied command line options when the option argument starts with
'{'
* The block layer's pseudo-protocol "json:" (which can get embedded in
image headers)
I *think* that's all.
The JSON parser we use for these interfaces supports extensions over RFC
8259. Quoting json-lexer.c:
- Extra escape sequence in strings:
0x27 (apostrophe) is recognized after escape, too
- Single-quoted strings:
Like double-quoted strings, except they're delimited by %x27
(apostrophe) instead of %x22 (quotation mark), and can't contain
unescaped apostrophe, but can contain unescaped quotation mark.
- Interpolation, if enabled:
The lexer accepts %[A-Za-z0-9]*, and leaves rejecting invalid
ones to the parser.
Ignore interpolation; it's never enabled at external interfaces.
This leaves single-quotes strings and the escape sequence to go with
them.
I disabled them as an experiment. Some 20 iotests, a qtest and two unit
tests explode.
The unit test testing the JSON parser is of course excused.
The remaining qtest and the unit test could perhaps be dismissed as
atypical use of QEMU from C. The iotests less so, I think.
I looked at some iotest failures, and quickly found single-quoted
strings used with all external interfaces except for qemu-ga's QMP.
We could certainly tidy up the tests to stick to standard JSON.
However, the prevalence of single-quoted strings in iotests makes me
suspect that they are being used in the field as well. Deprecating the
extension is likely more trouble than it's worth.
Opinions?
3 years, 10 months
[PATCH python] iothread: fix memory access out of bounds
by Hogan Wang
From: suruifeng <suruifeng(a)huawei.com>
When the 'pcpu' is larger then the last 'iothr->cpumap' bits,
set the list element to False to avoid out of bounds access
'iothr->cpumap'.
Signed-off-by: suruifeng <suruifeng(a)huawei.com>
Reviewed-by: Hogan Wang <hogan.wang(a)huawei.com>
---
libvirt-override.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libvirt-override.c b/libvirt-override.c
index 1f55864..b099f51 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -1625,10 +1625,14 @@ libvirt_virDomainGetIOThreadInfo(PyObject *self ATTRIBUTE_UNUSED,
VIR_PY_TUPLE_SET_GOTO(iothrtpl, 1, iothrmap, cleanup);
for (pcpu = 0; pcpu < cpunum; pcpu++)
- VIR_PY_LIST_SET_GOTO(iothrmap, pcpu,
- PyBool_FromLong(VIR_CPU_USED(iothr->cpumap,
- pcpu)),
- cleanup);
+ if (VIR_CPU_MAPLEN(pcpu + 1) > iothr->cpumaplen) {
+ VIR_PY_LIST_SET_GOTO(iothrmap, pcpu, PyBool_FromLong(0), cleanup);
+ } else {
+ VIR_PY_LIST_SET_GOTO(iothrmap, pcpu,
+ PyBool_FromLong(VIR_CPU_USED(iothr->cpumap,
+ pcpu)),
+ cleanup);
+ }
}
py_retval = py_iothrinfo;
--
2.23.0
3 years, 10 months
[libvirt PATCH] NEWS: mention cgroups on hosts with systemd bug fix
by Pavel Hrdina
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
NEWS.rst | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/NEWS.rst b/NEWS.rst
index bee49923a5..eac86d8a4e 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -71,6 +71,23 @@ v7.1.0 (unreleased)
of relying on ``VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE`` if they need finer
grained control.
+ * cgroups: Fix how we setup and configure cgroups on hosts with systemd
+
+ When libvirt is running on host with systemd we register every VM with
+ machined which creates the VM root cgroup for us as well. Before this fix
+ we were directly modifying files in the VM root cgroup which was incorrect
+ because all the files are managed by systemd. The implication was that any
+ change done by libvirt to cgroup attributes supported by systemd could be
+ removed which happens for example by running ``systemctl daemon-reload``.
+
+ To fix the issue libvirt now uses DBus calls for some of the cgroup
+ attributes that distributes the resources proportionally to the cgroup
+ siblings and for the rest we have new sub-cgroup that libvirt can managed
+ directly.
+
+ For more details why this is necessary see
+ `systemd cgroug <https://systemd.io/CGROUP_DELEGATION/>`_ documentation.
+
v7.0.0 (2021-01-15)
===================
--
2.29.2
3 years, 10 months
[PATCH RESEND 00/20] handle missing SR-IOV VF hostdevs during running domains
by Daniel Henrique Barboza
This is the rebased version of
https://www.redhat.com/archives/libvir-list/2021-January/msg00028.html
with master at 57b1ddcaaa5b5. No changes made aside from trivial conflicts
fixes.
I also removed the military jargon from the previous subject to make it
clear what this series is doing.
Daniel Henrique Barboza (20):
virpci, domain_audit: use virPCIDeviceAddressAsString()
qemu, lxc: move NodeDeviceGetPCIInfo() function to domain_driver.c
domain_driver.c: use PCI address with
virDomainDriverNodeDeviceGetPCIInfo()
virpci.c: simplify virPCIDeviceNew() signature
virpci: introduce virPCIDeviceExists()
virhostdev.c: virHostdevGetPCIHostDevice() now reports missing device
security_selinux.c: modernize set/restore hostdev subsys label
functions
security_dac.c: modernize hostdev label set/restore functions
dac, selinux: skip setting/restoring label for absent PCI devices
libvirt-nodedev.c: remove return value from virNodeDeviceFree()
qemu_driver.c: modernize qemuNodeDeviceReAttach()
libxl_driver.c: modernize libxlNodeDeviceReAttach()
virsh-domain.c: modernize cmdDetachDevice()
virhostdev.c: add virHostdevIsPCIDevice() helper
qemu_cgroup.c: skip absent PCI devices in qemuTeardownHostdevCgroup()
virpci.c: use virPCIDeviceAddressPtr in virPCIDeviceListFindIndex()
virpci.c: use virPCIDeviceAddressPtr in virPCIDeviceListFind()
virpci.c: use virPCIDeviceAddressPtr in virPCIDeviceListSteal()
virpci.c: use virPCIDeviceAddressPtr in virPCIDeviceListDel()
virhostdev.c: remove missing PCI devs from hostdev manager
include/libvirt/libvirt-nodedev.h | 2 +-
src/conf/domain_audit.c | 6 +-
src/datatypes.h | 2 +
src/hypervisor/domain_driver.c | 30 ++++++++++
src/hypervisor/domain_driver.h | 4 ++
src/hypervisor/virhostdev.c | 88 ++++++++++++++++++++++------
src/hypervisor/virhostdev.h | 2 +
src/libvirt-nodedev.c | 15 +++--
src/libvirt_private.syms | 3 +
src/libxl/libxl_driver.c | 87 ++++++++--------------------
src/node_device/node_device_udev.c | 11 ++--
src/qemu/qemu_cgroup.c | 10 ++++
src/qemu/qemu_domain_address.c | 5 +-
src/qemu/qemu_driver.c | 81 +++++++-------------------
src/security/security_apparmor.c | 3 +-
src/security/security_dac.c | 61 ++++++++------------
src/security/security_selinux.c | 66 +++++++++------------
src/security/virt-aa-helper.c | 6 +-
src/util/virnetdev.c | 3 +-
src/util/virnvme.c | 5 +-
src/util/virpci.c | 93 ++++++++++++++----------------
src/util/virpci.h | 14 ++---
tests/virhostdevtest.c | 3 +-
tests/virpcitest.c | 35 ++++++++---
tools/virsh-domain.c | 18 ++----
25 files changed, 325 insertions(+), 328 deletions(-)
--
2.26.2
3 years, 10 months
[PATCH] libxl: Fix domain shutdown
by Jim Fehlig
Commit fa30ee04a2 caused a regression in normal domain shutown.
Initiating a shutdown from within the domain or via 'virsh shutdown'
does cause the guest OS running in the domain to shutdown, but libvirt
never reaps the domain so it is always shown in a running state until
calling 'virsh destroy'.
The shutdown thread is also an internal user of the driver shutdown
machinery and eventually calls libxlDomainDestroyInternal where
the ignoreDeathEvent inhibitor is set, but running in a thread
introduces the possibility of racing with the death event from
libxl. This can be prevented by setting ignoreDeathEvent before
running the shutdown thread.
An additional improvement is to handle the destroy event synchronously
instead of spawning a thread. The time consuming aspects of destroying
a domain have been completed when the destroy event is delivered.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_domain.c | 115 ++++++++++++++++++---------------------
1 file changed, 54 insertions(+), 61 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index d59153fffa..32dc503089 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -476,6 +476,7 @@ libxlDomainShutdownHandleRestart(libxlDriverPrivatePtr driver,
struct libxlShutdownThreadInfo
{
libxlDriverPrivatePtr driver;
+ virDomainObjPtr vm;
libxl_event *event;
};
@@ -484,7 +485,7 @@ static void
libxlDomainShutdownThread(void *opaque)
{
struct libxlShutdownThreadInfo *shutdown_info = opaque;
- virDomainObjPtr vm = NULL;
+ virDomainObjPtr vm = shutdown_info->vm;
libxl_event *ev = shutdown_info->event;
libxlDriverPrivatePtr driver = shutdown_info->driver;
virObjectEventPtr dom_event = NULL;
@@ -494,12 +495,6 @@ libxlDomainShutdownThread(void *opaque)
libxl_domain_config_init(&d_config);
- vm = virDomainObjListFindByID(driver->domains, ev->domid);
- if (!vm) {
- VIR_INFO("Received event for unknown domain ID %d", ev->domid);
- goto cleanup;
- }
-
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
goto cleanup;
@@ -616,32 +611,18 @@ libxlDomainShutdownThread(void *opaque)
}
static void
-libxlDomainDeathThread(void *opaque)
+libxlDomainHandleDeath(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
{
- struct libxlShutdownThreadInfo *shutdown_info = opaque;
- virDomainObjPtr vm = NULL;
- libxl_event *ev = shutdown_info->event;
- libxlDriverPrivatePtr driver = shutdown_info->driver;
virObjectEventPtr dom_event = NULL;
- g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
- libxlDomainObjPrivatePtr priv;
-
- vm = virDomainObjListFindByID(driver->domains, ev->domid);
- if (!vm) {
- /* vm->def->id already cleared, means the death was handled by the
- * driver already */
- goto cleanup;
- }
-
- priv = vm->privateData;
+ libxlDomainObjPrivatePtr priv = vm->privateData;
if (priv->ignoreDeathEvent) {
priv->ignoreDeathEvent = false;
- goto cleanup;
+ return;
}
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
- goto cleanup;
+ return;
virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_DESTROYED);
dom_event = virDomainEventLifecycleNewFromObj(vm,
@@ -651,12 +632,7 @@ libxlDomainDeathThread(void *opaque)
if (!vm->persistent)
virDomainObjListRemove(driver->domains, vm);
libxlDomainObjEndJob(driver, vm);
-
- cleanup:
- virDomainObjEndAPI(&vm);
virObjectEventStateQueue(driver->domainEventState, dom_event);
- libxl_event_free(cfg->ctx, ev);
- VIR_FREE(shutdown_info);
}
@@ -668,16 +644,13 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
{
libxlDriverPrivatePtr driver = data;
libxl_shutdown_reason xl_reason = event->u.domain_shutdown.shutdown_reason;
- struct libxlShutdownThreadInfo *shutdown_info = NULL;
- virThread thread;
+ virDomainObjPtr vm = NULL;
g_autoptr(libxlDriverConfig) cfg = NULL;
- int ret = -1;
- g_autofree char *name = NULL;
if (event->type != LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN &&
event->type != LIBXL_EVENT_TYPE_DOMAIN_DEATH) {
VIR_INFO("Unhandled event type %d", event->type);
- goto error;
+ goto cleanup;
}
/*
@@ -685,42 +658,62 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
* after calling libxl_domain_suspend() are handled by its callers.
*/
if (xl_reason == LIBXL_SHUTDOWN_REASON_SUSPEND)
- goto error;
+ goto cleanup;
- /*
- * Start a thread to handle shutdown. We don't want to be tying up
- * libxl's event machinery by doing a potentially lengthy shutdown.
- */
- shutdown_info = g_new0(struct libxlShutdownThreadInfo, 1);
+ vm = virDomainObjListFindByID(driver->domains, event->domid);
+ if (!vm) {
+ /* Nothing to do if we can't find the virDomainObj */
+ goto cleanup;
+ }
- shutdown_info->driver = driver;
- shutdown_info->event = (libxl_event *)event;
- name = g_strdup_printf("ev-%d", event->domid);
- if (event->type == LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN)
- ret = virThreadCreateFull(&thread, false, libxlDomainShutdownThread,
- name, false, shutdown_info);
- else if (event->type == LIBXL_EVENT_TYPE_DOMAIN_DEATH)
- ret = virThreadCreateFull(&thread, false, libxlDomainDeathThread,
- name, false, shutdown_info);
+ if (event->type == LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN) {
+ libxlDomainObjPrivatePtr priv = vm->privateData;
+ struct libxlShutdownThreadInfo *shutdown_info = NULL;
+ virThread thread;
+ g_autofree char *name = NULL;
- if (ret < 0) {
/*
- * Not much we can do on error here except log it.
+ * Start a thread to handle shutdown. We don't want to be tying up
+ * libxl's event machinery by doing a potentially lengthy shutdown.
*/
- VIR_ERROR(_("Failed to create thread to handle domain shutdown"));
- goto error;
- }
+ shutdown_info = g_new0(struct libxlShutdownThreadInfo, 1);
- /*
- * libxlShutdownThreadInfo and libxl_event are freed in shutdown thread
- */
- return;
+ shutdown_info->driver = driver;
+ shutdown_info->vm = vm;
+ shutdown_info->event = (libxl_event *)event;
+ name = g_strdup_printf("ev-%d", event->domid);
+ /*
+ * Cleanup will be handled by the shutdown thread.
+ * Ignore the forthcoming death event from libxl
+ */
+ priv->ignoreDeathEvent = true;
+ if (virThreadCreateFull(&thread, false, libxlDomainShutdownThread,
+ name, false, shutdown_info) < 0) {
+ /*
+ * Not much we can do on error here except log it.
+ */
+ VIR_ERROR(_("Failed to create thread to handle domain shutdown"));
+ VIR_FREE(shutdown_info);
+ goto cleanup;
+ }
+ /*
+ * virDomainObjEndAPI is called in the shutdown thread, where
+ * libxlShutdownThreadInfo and libxl_event are also freed.
+ */
+ return;
+ } else if (event->type == LIBXL_EVENT_TYPE_DOMAIN_DEATH) {
+ /*
+ * On death the domain is cleaned up from Xen's perspective.
+ * Cleanup on the libvirt side can be done synchronously.
+ */
+ libxlDomainHandleDeath(driver, vm);
+ }
- error:
+ cleanup:
+ virDomainObjEndAPI(&vm);
cfg = libxlDriverConfigGet(driver);
/* Cast away any const */
libxl_event_free(cfg->ctx, (libxl_event *)event);
- VIR_FREE(shutdown_info);
}
char *
--
2.29.2
3 years, 10 months
[PATCH v2 RESEND 00/13] Introduce virtio-mem <memory/> model
by Michal Privoznik
Resend of:
https://listman.redhat.com/archives/libvir-list/2021-February/msg00534.html
We had couple of changes made (new capabilities added mostly) and the
original patch set no long applies cleanly. This is pure rebase of the
original patch set, no functional change (hence I'm keeping version
number).
Michal Prívozník (13):
virhostmem: Introduce virHostMemGetTHPSize()
qemu_process: Deduplicate code in qemuProcessNeedHugepagesPath()
qemu_process: Drop needless check in
qemuProcessNeedMemoryBackingPath()
qemu_capabilities: Introduce QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI
conf: Introduce virtio-mem <memory/> model
qemu: Build command line for virtio-mem
qemu: Wire up <memory/> live update
qemu: Wire up MEMORY_DEVICE_SIZE_CHANGE event
Introduce MEMORY_DEVICE_SIZE_CHANGE event
qemu: Refresh the actual size of virtio-mem on monitor reconnect
virsh: Introduce update-memory command
news: document recent virtio memory addition
kbase: Document virtio-mem
NEWS.rst | 7 +
docs/formatdomain.rst | 58 ++++-
docs/kbase/index.rst | 4 +
docs/kbase/memorydevices.rst | 160 ++++++++++++++
docs/kbase/meson.build | 1 +
docs/manpages/virsh.rst | 30 +++
docs/schemas/domaincommon.rng | 16 ++
examples/c/misc/event-test.c | 17 ++
include/libvirt/libvirt-domain.h | 23 ++
src/conf/domain_conf.c | 115 +++++++++-
src/conf/domain_conf.h | 15 ++
src/conf/domain_event.c | 84 +++++++
src/conf/domain_event.h | 10 +
src/conf/domain_validate.c | 39 ++++
src/libvirt_private.syms | 5 +
src/qemu/qemu_alias.c | 10 +-
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 13 +-
src/qemu/qemu_domain.c | 67 +++++-
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_domain_address.c | 38 +++-
src/qemu/qemu_driver.c | 209 +++++++++++++++++-
src/qemu/qemu_hotplug.c | 18 ++
src/qemu/qemu_hotplug.h | 5 +
src/qemu/qemu_monitor.c | 37 ++++
src/qemu/qemu_monitor.h | 27 +++
src/qemu/qemu_monitor_json.c | 95 ++++++--
src/qemu/qemu_monitor_json.h | 5 +
src/qemu/qemu_process.c | 101 +++++++--
src/qemu/qemu_validate.c | 22 +-
src/remote/remote_daemon_dispatch.c | 30 +++
src/remote/remote_driver.c | 32 +++
src/remote/remote_protocol.x | 15 +-
src/remote_protocol-structs | 7 +
src/security/security_apparmor.c | 1 +
src/security/security_dac.c | 2 +
src/security/security_selinux.c | 2 +
src/util/virhostmem.c | 63 ++++++
src/util/virhostmem.h | 3 +
tests/domaincapsmock.c | 9 +
.../caps_5.1.0.x86_64.xml | 1 +
.../caps_5.2.0.x86_64.xml | 1 +
.../caps_6.0.0.x86_64.xml | 1 +
...mory-hotplug-virtio-mem.x86_64-latest.args | 48 ++++
.../memory-hotplug-virtio-mem.xml | 64 ++++++
tests/qemuxml2argvtest.c | 1 +
...emory-hotplug-virtio-mem.x86_64-latest.xml | 1 +
tests/qemuxml2xmltest.c | 1 +
tools/virsh-domain.c | 170 ++++++++++++++
50 files changed, 1619 insertions(+), 68 deletions(-)
create mode 100644 docs/kbase/memorydevices.rst
create mode 100644 tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/memory-hotplug-virtio-mem.xml
create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-virtio-mem.x86_64-latest.xml
--
2.26.2
3 years, 10 months