[PATCH 2/2] balloon: add VIRTIO_BALLOON_F_DEVICE_INIT_DEFLATED

"Michael S. Tsirkin" <[email protected]> Wed, 22 Apr 2026 12:12:08 -0400
Newsgroups dev.linux.lists.virtio-comment
Message-ID <24ed09fb89c1a48b39fc812b765bea10763860ef.1776874126.git.mst@redhat.com>
Same idea as DEVICE_INIT_REPORTED but for deflation.
The device has been holding these pages since inflate, so
it can guarantee initialization of all of them. Make this
all-or-nothing: the device must not offer the feature if it
cannot initialize every page.

Fixes: https://github.com/oasis-tcs/virtio-spec/issues/242
Signed-off-by: Michael S. Tsirkin <[email protected]>
---
 device-types/balloon/description.tex        | 48 +++++++++++++++++++++
 device-types/balloon/device-conformance.tex |  1 +
 device-types/balloon/driver-conformance.tex |  1 +
 3 files changed, 50 insertions(+)

diff --git a/device-types/balloon/description.tex b/device-types/balloon/description.tex
index 144983b..7470763 100644
--- a/device-types/balloon/description.tex
+++ b/device-types/balloon/description.tex
@@ -55,6 +55,12 @@ \subsection{Feature bits}\label{sec:Device Types / Memory Balloon Device / Featu
     are filled with zeros. A bitmap indicating which pages were
     successfully initialized is returned to the driver.
 
+\item[ VIRTIO_BALLOON_F_DEVICE_INIT_DEFLATED(7) ] The device initializes
+    deflated pages before returning them to the driver. If
+    VIRTIO_BALLOON_F_PAGE_POISON is also negotiated, deflated pages
+    are filled with \field{poison_val}; otherwise, they are filled
+    with zeros.
+
 \end{description}
 
 \drivernormative{\subsubsection}{Feature bits}{Device Types / Memory Balloon Device / Feature bits}
@@ -692,3 +698,45 @@ \subsubsection{Device Initialized Reported Pages}\label{sec:Device Types / Memor
 
 If VIRTIO_BALLOON_F_PAGE_POISON is not negotiated, the device
 MUST fill each successfully initialized page with zeros.
+
+\subsubsection{Device Initialized Deflated Pages}\label{sec:Device Types / Memory Balloon Device / Device Operation / Device Initialized Deflated Pages}
+
+Device Initialized Deflated Pages provides a mechanism for the device
+to initialize deflated pages before returning them to the driver. When
+this feature is negotiated, the device fills all deflated pages with
+the appropriate initialization value before acknowledging the deflate
+request.
+
+If VIRTIO_BALLOON_F_PAGE_POISON is also negotiated, the device fills
+pages with \field{poison_val}; otherwise, the device fills pages
+with zeros.
+
+\drivernormative{\paragraph}{Device Initialized Deflated Pages}{Device Types / Memory Balloon Device / Device Operation / Device Initialized Deflated Pages}
+
+Normative statements in this section apply if the
+VIRTIO_BALLOON_F_DEVICE_INIT_DEFLATED feature has been negotiated.
+
+The driver MUST NOT assume deflated pages are initialized until
+the device has acknowledged the deflate request.
+
+The driver MAY use deflated pages without initializing them, as they
+are guaranteed to be initialized once the deflate request is
+acknowledged.
+
+If VIRTIO_BALLOON_F_PAGE_POISON is also negotiated, the driver
+need not initialize deflated pages with \field{poison_val},
+as the device has already done so.
+
+\devicenormative{\paragraph}{Device Initialized Deflated Pages}{Device Types / Memory Balloon Device / Device Operation / Device Initialized Deflated Pages}
+
+Normative statements in this section apply if the
+VIRTIO_BALLOON_F_DEVICE_INIT_DEFLATED feature has been negotiated.
+
+The device MUST fill all deflated pages with the initialization value
+before acknowledging the deflate request.
+
+If VIRTIO_BALLOON_F_PAGE_POISON is also negotiated, the device
+MUST fill each deflated page with \field{poison_val}.
+
+If VIRTIO_BALLOON_F_PAGE_POISON is not negotiated, the device
+MUST fill each deflated page with zeros.
diff --git a/device-types/balloon/device-conformance.tex b/device-types/balloon/device-conformance.tex
index 1d4df8c..dfa00c2 100644
--- a/device-types/balloon/device-conformance.tex
+++ b/device-types/balloon/device-conformance.tex
@@ -10,4 +10,5 @@
 \item \ref{devicenormative:Device Types / Memory Balloon Device / Device Operation / Page Poison}
 \item \ref{devicenormative:Device Types / Memory Balloon Device / Device Operation / Free Page Reporting}
 \item \ref{devicenormative:Device Types / Memory Balloon Device / Device Operation / Device Initialized Reported Pages}
+\item \ref{devicenormative:Device Types / Memory Balloon Device / Device Operation / Device Initialized Deflated Pages}
 \end{itemize}
diff --git a/device-types/balloon/driver-conformance.tex b/device-types/balloon/driver-conformance.tex
index 6e5ccf0..c35f6fa 100644
--- a/device-types/balloon/driver-conformance.tex
+++ b/device-types/balloon/driver-conformance.tex
@@ -10,4 +10,5 @@
 \item \ref{drivernormative:Device Types / Memory Balloon Device / Device Operation / Page Poison}
 \item \ref{drivernormative:Device Types / Memory Balloon Device / Device Operation / Free Page Reporting}
 \item \ref{drivernormative:Device Types / Memory Balloon Device / Device Operation / Device Initialized Reported Pages}
+\item \ref{drivernormative:Device Types / Memory Balloon Device / Device Operation / Device Initialized Deflated Pages}
 \end{itemize}
-- 
MST