diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 1a9550e438ae0dd9a5fb55bc48ca79cae5dba404..b2ab2c08e3acbb7ae53e4647c06ae3ae86fbf010 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1055,6 +1055,8 @@ static char *lxcConnectDomainXMLFromNative(virConnectPtr conn, { char *xml = NULL; virDomainDefPtr def = NULL; + virLXCDriverPtr driver = conn->privateData; + virCapsPtr caps = virLXCDriverGetCapabilities(driver, false); virCheckFlags(0, NULL); @@ -1067,12 +1069,13 @@ static char *lxcConnectDomainXMLFromNative(virConnectPtr conn, goto cleanup; } - if (!(def = lxcParseConfigString(nativeConfig))) + if (!(def = lxcParseConfigString(nativeConfig, caps, driver->xmlopt))) goto cleanup; xml = virDomainDefFormat(def, 0); cleanup: + virObjectUnref(caps); virDomainDefFree(def); return xml; } diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 2f9559735a46f8f3ca7928fa6899eb64a2f66b72..8ff2253b46cc2f15b5a555c916fce0b68e019fc9 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -991,7 +991,9 @@ lxcSetCapDrop(virDomainDefPtr def, virConfPtr properties) } virDomainDefPtr -lxcParseConfigString(const char *config) +lxcParseConfigString(const char *config, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt) { virDomainDefPtr vmdef = NULL; virConfPtr properties = NULL; @@ -1088,6 +1090,10 @@ lxcParseConfigString(const char *config) /* lxc.cap.drop */ lxcSetCapDrop(vmdef, properties); + if (virDomainDefPostParse(vmdef, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, + xmlopt) < 0) + goto cleanup; + goto cleanup; error: diff --git a/src/lxc/lxc_native.h b/src/lxc/lxc_native.h index a80f2b1eaf11d0faeed99b99fb0391e00dc2c5c0..15fa0d54748797b4f7f16c77aa3ce41e2e55e203 100644 --- a/src/lxc/lxc_native.h +++ b/src/lxc/lxc_native.h @@ -27,6 +27,8 @@ # define LXC_CONFIG_FORMAT "lxc-tools" -virDomainDefPtr lxcParseConfigString(const char *config); +virDomainDefPtr lxcParseConfigString(const char *config, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt); #endif /* __LXC_NATIVE_H__ */ diff --git a/tests/Makefile.am b/tests/Makefile.am index e1e28eca93f1c5ad242261b5714a5d08f5449b69..1d57b391084adc27e69b055cdbc8181c54995103 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -659,7 +659,7 @@ lxcxml2xmltest_SOURCES = \ lxcxml2xmltest_LDADD = $(lxc_LDADDS) lxcconf2xmltest_SOURCES = \ - lxcconf2xmltest.c \ + lxcconf2xmltest.c testutilslxc.c testutilslxc.h \ testutils.c testutils.h lxcconf2xmltest_LDADD = $(lxc_LDADDS) else ! WITH_LXC diff --git a/tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml b/tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml index c9c046969ace4f3aa41253eacc2da5fa4b224115..641edb94fab66777eb7189cb75fd0334876ae449 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 65536 - 0 + 65536 500 @@ -33,6 +33,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml index e7863fa13f84e7356af174bffe480efedd7e2c04..bafaa960f8839f7ae3f4ffb8e3578bdbf440ad0d 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 65536 - 0 + 65536 1 @@ -21,6 +21,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml b/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml index 50c5358abef63accd9ffff30fac8ac6992f58a71..f7f8041dd6d2667676824ae1e183383440aaa74f 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 65536 - 0 + 65536 1 1024 @@ -23,6 +23,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml b/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml index 80a83ff78ab0624ac97b962a883d42c7f260137e..dd3843d5cbdd594635e98455a17fe44e1148f384 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 65536 - 0 + 65536 1 exe @@ -22,6 +22,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml index 3105b8cefc9322f335207b296703686a0401e47c..a345e8e019e2436a68fdb18be4c527a5795e7474 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 65536 - 0 + 65536 1 exe @@ -17,6 +17,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml b/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml index 7df1ef0e98b0e9278750806e41a31b627d18093a..57e751aabab88de5ab6da73175cfcdc02081ef2d 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 1048576 - 0 + 1048576 1048576 131072 @@ -23,6 +23,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml index e002b99a6625317e7b27fa2f892029fe5f60561c..0122ab05c7a059a9f95aa5d111e8be7c2276fc2f 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 65536 - 0 + 65536 1 exe @@ -17,6 +17,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml index dc9d6350f5c67e98682f4345e5c857ce9d730891..04ea280b3c3adbee02c60b7c4018a5e3394f9895 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 65536 - 0 + 65536 1 exe @@ -18,6 +18,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml index 79bcfa003ef2d9291d2bdce9505ce4207bd2a799..4fb3f954e02c03638656922e589300dd3101ff3c 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 65536 - 0 + 65536 1 exe @@ -17,6 +17,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmldata/lxcconf2xml-simple.xml b/tests/lxcconf2xmldata/lxcconf2xml-simple.xml index 45a2012c5ad64c7c2d763aa0d695a890405043e5..5234bab7f2007fa10ddd0bc9c397b9340242389f 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-simple.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-simple.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 65536 - 0 + 65536 1 exe @@ -21,6 +21,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml index 712be3e1ec45f59da6712942cc266f4b476b21bb..47ed898b0f1ad2b81d049dc826947231048ae6d6 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml @@ -2,7 +2,7 @@ migrate_test c7a5fdbd-edaf-9455-926a-d65c16db1809 65536 - 0 + 65536 1 exe @@ -17,6 +17,7 @@ restart destroy + /usr/libexec/libvirt_lxc diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index 6255942cb0cb35db87f18e22b3b323f6dce0e3f5..ed21e8a389be256552b10b3b0aa33ac67d6ef709 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -5,9 +5,14 @@ #ifdef WITH_LXC # include "lxc/lxc_native.h" +# include "lxc/lxc_conf.h" +# include "testutilslxc.h" # define VIR_FROM_THIS VIR_FROM_NONE +static virCapsPtr caps; +static virDomainXMLOptionPtr xmlopt; + static int blankProblemElements(char *data) { @@ -30,7 +35,7 @@ testCompareXMLToConfigFiles(const char *xml, if (virtTestLoadFile(configfile, &config) < 0) goto fail; - vmdef = lxcParseConfigString(config); + vmdef = lxcParseConfigString(config, caps, xmlopt); if ((vmdef && expectError) || (!vmdef && !expectError)) goto fail; @@ -93,6 +98,14 @@ mymain(void) { int ret = EXIT_SUCCESS; + if (!(caps = testLXCCapsInit())) + return EXIT_FAILURE; + + if (!(xmlopt = lxcDomainXMLConfInit())) { + virObjectUnref(caps); + return EXIT_FAILURE; + } + # define DO_TEST(name, expectError) \ do { \ const struct testInfo info = { name, expectError }; \ @@ -115,6 +128,9 @@ mymain(void) DO_TEST("cpusettune", false); DO_TEST("blkiotune", false); + virObjectUnref(xmlopt); + virObjectUnref(caps); + return ret; }