Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/lxc/lxc_driver.c | 5 ++++- src/lxc/lxc_native.c | 8 +++++++- src/lxc/lxc_native.h | 4 +++- tests/Makefile.am | 2 +- tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml | 3 ++- tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml | 3 ++- tests/lxcconf2xmldata/lxcconf2xml-cputune.xml | 3 ++- tests/lxcconf2xmldata/lxcconf2xml-idmap.xml | 3 ++- tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml | 3 ++- tests/lxcconf2xmldata/lxcconf2xml-memtune.xml | 3 ++- tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml | 3 ++- tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml | 3 ++- tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml | 3 ++- tests/lxcconf2xmldata/lxcconf2xml-simple.xml | 3 ++- tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml | 3 ++- tests/lxcconf2xmltest.c | 18 +++++++++++++++++- 16 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 1a9550e..b2ab2c0 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 2f95597..8ff2253 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 a80f2b1..15fa0d5 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 e1e28ec..1d57b39 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 c9c0469..641edb9 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>65536</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>65536</currentMemory> <blkiotune> <weight>500</weight> <device> @@ -33,6 +33,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml index e7863fa..bafaa96 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>65536</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>65536</currentMemory> <vcpu placement='static' cpuset='1-2,5-7'>1</vcpu> <numatune> <memory mode='strict' nodeset='1-4'/> @@ -21,6 +21,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml b/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml index 50c5358..f7f8041 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>65536</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>65536</currentMemory> <vcpu placement='static'>1</vcpu> <cputune> <shares>1024</shares> @@ -23,6 +23,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml b/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml index 80a83ff..dd3843d 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>65536</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>65536</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type>exe</type> @@ -22,6 +22,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml index 3105b8c..a345e8e 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>65536</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>65536</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type>exe</type> @@ -17,6 +17,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml b/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml index 7df1ef0..57e751a 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>1048576</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>1048576</currentMemory> <memtune> <hard_limit unit='KiB'>1048576</hard_limit> <soft_limit unit='KiB'>131072</soft_limit> @@ -23,6 +23,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml index e002b99..0122ab0 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>65536</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>65536</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type>exe</type> @@ -17,6 +17,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml index dc9d635..04ea280 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>65536</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>65536</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type>exe</type> @@ -18,6 +18,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml index 79bcfa0..4fb3f95 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>65536</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>65536</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type>exe</type> @@ -17,6 +17,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-simple.xml b/tests/lxcconf2xmldata/lxcconf2xml-simple.xml index 45a2012..5234bab 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-simple.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-simple.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>65536</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>65536</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type arch='i686'>exe</type> @@ -21,6 +21,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml index 712be3e..47ed898 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml @@ -2,7 +2,7 @@ <name>migrate_test</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> <memory unit='KiB'>65536</memory> - <currentMemory unit='KiB'>0</currentMemory> + <currentMemory unit='KiB'>65536</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type>exe</type> @@ -17,6 +17,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/lxc/migrate_test/rootfs'/> <target dir='/'/> diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index 6255942..ed21e8a 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; } -- 2.6.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list