diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 53389b07825d142f016676418f4eb4e0b21a9c6e..0d97044a082d2bb3ecc9d80588f91547857c304c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3077,10 +3077,6 @@
@@ -3122,6 +3118,7 @@
-1
+
[0-9]+
@@ -3133,7 +3130,6 @@
[0-9]+
- 4000
@@ -3145,7 +3141,6 @@
[0-9]+
- 4000
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6162c4ed4e4bed804cd3c9bab0ef577e6d59cc72..16ab9d40228c81fb72cfaae36deaea81e6c108a2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7625,6 +7625,13 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
&def->mem.cur_balloon) < 0)
def->mem.cur_balloon = def->mem.max_balloon;
+ if (def->mem.cur_balloon > def->mem.max_balloon) {
+ virDomainReportError(VIR_ERR_XML_ERROR,
+ _("current memory '%luk' exceeds maximum '%luk'"),
+ def->mem.cur_balloon, def->mem.max_balloon);
+ goto error;
+ }
+
node = virXPathNode("./memoryBacking/hugepages", ctxt);
if (node)
def->mem.hugepage_backed = 1;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.xml b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.xml
index 1914c6bcc538b0a693206cb8cbd78c2e4bf08e16..32560106ff71b3cd954cedb5541f48435bb1171f 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.xml b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.xml
index 2f5806808ec2acfcf3662f5b9c2dcaedd09a0d48..d91afcc4bf91d2999bf1a857dd12b0b1779a4791 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.xml b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.xml
index b0415b341437c699c1765b7e4b3dedf7e738e6a0..7069279226f3a1299a94a697437b318ddbf270fc 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.xml b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.xml
index 33e2ee4067284efbe33fc06d695509d2bbaf304a..db42a116bceaf97866a7b1f95144847b65dcdd75 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.xml b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.xml
index 92fb31d1024e0106b99ccc2ce20b97cb7de2653f..05a93c3e1cb2e3dee78763a9018d5dfa8674b5ea 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-controller.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller.xml
index 45d81b6957fa18ac53755f0055cfa2f2221ffbe8..66657cfd2f498d05da6e9826a79ab5c5f9ecdb19 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-controller.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-hub.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-hub.xml
index 14490e5058367089f66fafa801d18f4cfdaee57c..c01301443d6965666b09b0274880ecec9b4b331e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-hub.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-hub.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-companion.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-companion.xml
index b7b47cdac6d0e87af17db367a1ab80b919acf7b5..d12f67e38989942de488650fef82ea324849c2aa 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-companion.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-companion.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml
index 3237ef9e2f73b2c64c536264eab4460ad4cb331a..aa6c092f3eb25f4b22a47340095c9525a286f8a1 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-piix3-controller.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-piix3-controller.xml
index d233544d96c8498f57e2565f12971fc36d9699a4..58dbfb1a8928044109677922e72e16a59662b3ee 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-piix3-controller.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-piix3-controller.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-ports.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-ports.xml
index 0cedf8714b10b59f713e90c5dfa82290f3ac90e1..a6eebf5c08f47bf8be6de941154bbac2b1783af6 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-ports.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-ports.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.xml
index b0e8b4545c53afe106c7784d5f601b708bcd3ad1..fd23ec8024f9a05af5e2393a2d32ea0603ad1275 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb1-usb2.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb1-usb2.xml
index 572cb2b516afdc15d618f9dc947a0d63f6c51935..b8a2ccfe43fd4827414de7ee00e243d7800448c5 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb1-usb2.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb1-usb2.xml
@@ -2,7 +2,7 @@
QEMUGuest1
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
- 219200
+ 219136
1
hvm