Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
e4cbfa71
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e4cbfa71
编写于
5月 11, 2016
作者:
J
Ján Tomko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Separate virDomainDefParseBootOptions
Split out parsing of most of the <os> subelements into a separate function.
上级
2d394090
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
83 addition
and
63 deletion
+83
-63
src/conf/domain_conf.c
src/conf/domain_conf.c
+83
-63
未找到文件。
src/conf/domain_conf.c
浏览文件 @
e4cbfa71
...
...
@@ -15105,6 +15105,87 @@ virDomainVcpuParse(virDomainDefPtr def,
return ret;
}
static int
virDomainDefParseBootOptions(virDomainDefPtr def,
xmlXPathContextPtr ctxt,
virHashTablePtr *bootHash)
{
xmlNodePtr *nodes = NULL;
int ret = -1;
size_t i;
int n;
/*
* Booting options for different OS types....
*
* - A bootloader (and optional kernel+initrd) (xen)
* - A kernel + initrd (xen)
* - A boot device (and optional kernel+initrd) (hvm)
* - An init script (exe)
*/
if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
def->os.init = virXPathString("string(./os/init[1])", ctxt);
def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0)
goto error;
if (VIR_ALLOC_N(def->os.initargv, n+1) < 0)
goto error;
for (i = 0; i < n; i++) {
if (!nodes[i]->children ||
!nodes[i]->children->content) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("No data supplied for <initarg> element"));
goto error;
}
if (VIR_STRDUP(def->os.initargv[i],
(const char*) nodes[i]->children->content) < 0)
goto error;
}
def->os.initargv[n] = NULL;
VIR_FREE(nodes);
}
if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
def->os.type == VIR_DOMAIN_OSTYPE_HVM ||
def->os.type == VIR_DOMAIN_OSTYPE_UML) {
xmlNodePtr loader_node;
def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt);
def->os.initrd = virXPathString("string(./os/initrd[1])", ctxt);
def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
def->os.dtb = virXPathString("string(./os/dtb[1])", ctxt);
def->os.root = virXPathString("string(./os/root[1])", ctxt);
if ((loader_node = virXPathNode("./os/loader[1]", ctxt))) {
if (VIR_ALLOC(def->os.loader) < 0)
goto error;
if (virDomainLoaderDefParseXML(loader_node, def->os.loader) < 0)
goto error;
def->os.loader->nvram = virXPathString("string(./os/nvram[1])", ctxt);
def->os.loader->templt = virXPathString("string(./os/nvram[1]/@template)", ctxt);
}
}
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (virDomainDefParseBootXML(ctxt, def) < 0)
goto error;
if (!(*bootHash = virHashCreate(5, NULL)))
goto error;
}
ret = 0;
error:
VIR_FREE(nodes);
return ret;
}
static virDomainDefPtr
virDomainDefParseXML(xmlDocPtr xml,
xmlNodePtr root,
...
...
@@ -16080,69 +16161,8 @@ virDomainDefParseXML(xmlDocPtr xml,
}
VIR_FREE(nodes);
/*
* Booting options for different OS types....
*
* - A bootloader (and optional kernel+initrd) (xen)
* - A kernel + initrd (xen)
* - A boot device (and optional kernel+initrd) (hvm)
* - An init script (exe)
*/
if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
def->os.init = virXPathString("string(./os/init[1])", ctxt);
def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0)
goto error;
if (VIR_ALLOC_N(def->os.initargv, n+1) < 0)
goto error;
for (i = 0; i < n; i++) {
if (!nodes[i]->children ||
!nodes[i]->children->content) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("No data supplied for <initarg> element"));
goto error;
}
if (VIR_STRDUP(def->os.initargv[i],
(const char*) nodes[i]->children->content) < 0)
goto error;
}
def->os.initargv[n] = NULL;
VIR_FREE(nodes);
}
if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
def->os.type == VIR_DOMAIN_OSTYPE_HVM ||
def->os.type == VIR_DOMAIN_OSTYPE_UML) {
xmlNodePtr loader_node;
def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt);
def->os.initrd = virXPathString("string(./os/initrd[1])", ctxt);
def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
def->os.dtb = virXPathString("string(./os/dtb[1])", ctxt);
def->os.root = virXPathString("string(./os/root[1])", ctxt);
if ((loader_node = virXPathNode("./os/loader[1]", ctxt))) {
if (VIR_ALLOC(def->os.loader) < 0)
goto error;
if (virDomainLoaderDefParseXML(loader_node, def->os.loader) < 0)
goto error;
def->os.loader->nvram = virXPathString("string(./os/nvram[1])", ctxt);
def->os.loader->templt = virXPathString("string(./os/nvram[1]/@template)", ctxt);
}
}
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (virDomainDefParseBootXML(ctxt, def) < 0)
goto error;
if (!(bootHash = virHashCreate(5, NULL)))
goto error;
}
if (virDomainDefParseBootOptions(def, ctxt, &bootHash) < 0)
goto error;
/* analysis of the disk devices */
if ((n = virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录