提交 1dc38b72 编写于 作者: P Pavel Hrdina

lxc: use virDomainDefPostParse for parsing LXC config string

This change ensures to call driver specific post-parse code to modify
domain definition after parsing hypervisor config the same way we do
after parsing XML.
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 eba20715
......@@ -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;
}
......
......@@ -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:
......
......@@ -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__ */
......@@ -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
......
......@@ -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='/'/>
......
......@@ -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='/'/>
......
......@@ -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='/'/>
......
......@@ -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='/'/>
......
......@@ -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='/'/>
......
......@@ -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='/'/>
......
......@@ -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='/'/>
......
......@@ -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='/'/>
......
......@@ -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='/'/>
......
......@@ -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='/'/>
......
......@@ -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='/'/>
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册