From 1b1402b90f335fc668b3781714d598d1ce9d5108 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 22 Feb 2012 21:18:39 -0700 Subject: [PATCH] xml: drop unenforced minimum memory limit from RNG The test domain allows 0, but the RNG was stating that memory had to be at least 4096000 bytes. Hypervisors should enforce their own limits, rather than complicating the RNG. Meanwhile, some copy and paste had introduced some fishy constructs in various unit tests. * docs/schemas/domaincommon.rng (memoryKB, memoryKBElement): Drop limit that isn't enforced in code. * src/conf/domain_conf.c (virDomainDefParseXML): Require current <= maximum. * tests/qemuxml2argvdata/*.xml: Fix offenders. --- docs/schemas/domaincommon.rng | 7 +------ src/conf/domain_conf.c | 7 +++++++ .../qemuxml2argvdata/qemuxml2argv-smartcard-controller.xml | 2 +- .../qemuxml2argv-smartcard-host-certificates.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.xml | 2 +- .../qemuxml2argv-smartcard-passthrough-spicevmc.xml | 2 +- .../qemuxml2argv-smartcard-passthrough-tcp.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-usb-controller.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-usb-hub.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-companion.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-usb-piix3-controller.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-usb-ports.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-usb-redir.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-usb1-usb2.xml | 2 +- 15 files changed, 21 insertions(+), 19 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 53389b0782..0d97044a08 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 6162c4ed4e..16ab9d4022 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 1914c6bcc5..32560106ff 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 2f5806808e..d91afcc4bf 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 b0415b3414..7069279226 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 33e2ee4067..db42a116bc 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 92fb31d102..05a93c3e1c 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 45d81b6957..66657cfd2f 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 14490e5058..c01301443d 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 b7b47cdac6..d12f67e389 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 3237ef9e2f..aa6c092f3e 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 d233544d96..58dbfb1a89 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 0cedf8714b..a6eebf5c08 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 b0e8b4545c..fd23ec8024 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 572cb2b516..b8a2ccfe43 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 -- 2.47.2