Virtuozzo QEMU development (svt-core@virtuozzo.com)
 help / color / mirror / Atom feed
From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
To: svt-core@virtuozzo.com
Cc: andrey.drobyshev@virtuozzo.com, efim.shevrin@virtuozzo.com,
	den@openvz.org
Subject: [RFC HCI-8.1 PATCH 5/5] qemu update: refuse PCI hostdevs on non-shared guest RAM #VSTOR-103860
Date: Fri,  9 Oct 2026 17:04:35 +0300	[thread overview]
Message-ID: <20261009140435.483100-6-andrey.drobyshev@virtuozzo.com> (raw)
In-Reply-To: <20261009140435.483100-1-andrey.drobyshev@virtuozzo.com>

New domains with PCI hostdevs get shared memfd guest RAM since the
previous commits, but not all running domains have it: those started
by an older libvirt, those with explicitly configured private memory
backing, and those that got a PCI hostdev hotplugged while running on
anonymous RAM.  For them qemu-update would succeed while silently
breaking the device: DMA keeps going to the pages pinned before the
exec, which the guest stops seeing on its first write to them.

Refuse qemu-update for a domain with PCI hostdevs unless all of its
guest RAM is shared.  A cold restart gives such a domain shared memfd
RAM, unless its memory backing is configured otherwise.

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
 src/qemu/qemu_driver.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b3902f10c65..c39e0133ebb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -25194,6 +25194,16 @@ qemuDomainGuestQemuUpdatePrechecks(virDomainObj *vm)
         return -1;
     }
 
+    /* Device DMA keeps going to the pages pinned before the exec, which the
+     * guest stops seeing on its first write if the RAM is private. */
+    if (virDomainDefHasPCIHostdev(vm->def) &&
+        !qemuDomainDefGuestRAMIsShared(vm->def)) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       _("VM '%1$s' has PCI hostdev on non-shared guest memory, qemu-update cancelled; a cold restart switches it to shared memory"),
+                       vm->def->name);
+        return -1;
+    }
+
     if (virDomainDefHasNVMeDisk(vm->def)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("VM '%1$s' has NVMe disk, qemu-update cancelled"),
-- 
2.47.1


      parent reply	other threads:[~2026-10-09 14:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 14:04 [RFC HCI-8.1 PATCH 0/5] qemu: allow qemu-update with VFIO hostdevs on shared memfd " Andrey Drobyshev
2026-10-09 14:04 ` [RFC HCI-8.1 PATCH 1/5] qemu update: allow qemu-update for VMs with PCI and USB hostdevs #VSTOR-103860 #VSTOR-137800 Andrey Drobyshev
2026-10-09 14:04 ` [RFC HCI-8.1 PATCH 2/5] qemu: capabilities: probe aux-ram-share machine property #VSTOR-103860 Andrey Drobyshev
2026-10-09 14:04 ` [RFC HCI-8.1 PATCH 3/5] qemu: back guest RAM with shared memfd for VMs with DMA-pinning devices #VSTOR-103860 Andrey Drobyshev
2026-10-09 14:04 ` [RFC HCI-8.1 PATCH 4/5] qemu: share auxiliary RAM of " Andrey Drobyshev
2026-10-09 14:04 ` Andrey Drobyshev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261009140435.483100-6-andrey.drobyshev@virtuozzo.com \
    --to=andrey.drobyshev@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=efim.shevrin@virtuozzo.com \
    --cc=svt-core@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox