首页 > 解决方案 > 在 Ubuntu 18.04 上为 virtiofs 构建(或只是获取)最新的 libvirtd

问题描述

请注意,我对 kvm 和 libvirt真的很陌生,所以这里可能缺少一些真正基础的东西。如果这真的是一个“阅读常见问题解答”类型的问题,我深表歉意,但到目前为止我还没有找到任何具体的东西。

通过 apt 在 Ubuntu 18.04 上安装 libvirt 会安装 4.0.0 版。我需要与客人共享主机文件夹,并希望确保体面的性能,所以我想试试 virtiofs。文档为此建议最低 6.2(实际上,只是放入<driver type='virtiofs'/>来宾配置会导致无法针对架构进行验证)。

我下载了 libvirt 源代码,但找不到完整的先决条件列表。我最终安装了这些configure以运行而不会抱怨:

apt install gcc libglib2.0-dev gnutls-dev libxml2-dev xsltproc python-docutils libdevmapper-dev libpciaccess-dev

然后我跑了../configure --without-macvtap(因为我使用的是桥接网络)。

此时,我可以运行make check,但最终会出现一串编译错误util/libvirt_util_la-virnetdev.lo(下面的完整错误输出)。我假设我仍然缺少一些先决条件,但是我在任何地方都找不到完整的列表,并且谷歌搜索这个错误也没有出现太多。我缺少的地方有一些构建说明吗?

# make check
make  check-recursive
make[1]: Entering directory '/root/libvirtd/libvirt-6.4.0/build'
Making check in .
make[2]: Entering directory '/root/libvirtd/libvirt-6.4.0/build'
make  check-local
make[3]: Entering directory '/root/libvirtd/libvirt-6.4.0/build'
make  all-recursive
make[4]: Entering directory '/root/libvirtd/libvirt-6.4.0/build'
Making all in .
make[5]: Entering directory '/root/libvirtd/libvirt-6.4.0/build'
make[5]: Leaving directory '/root/libvirtd/libvirt-6.4.0/build'
Making all in include/libvirt
make[5]: Entering directory '/root/libvirtd/libvirt-6.4.0/build/include/libvirt'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/root/libvirtd/libvirt-6.4.0/build/include/libvirt'
Making all in src
make[5]: Entering directory '/root/libvirtd/libvirt-6.4.0/build/src'
make  all-am
make[6]: Entering directory '/root/libvirtd/libvirt-6.4.0/build/src'
  CC       util/libvirt_util_la-virnetdev.lo
../../src/util/virnetdev.c: In function 'virNetDevGetFamilyId':
../../src/util/virnetdev.c:2980:12: error: variable 'gmsgh' has initializer but incomplete type
     struct genlmsghdr gmsgh = {
            ^~~~~~~~~~
../../src/util/virnetdev.c:2981:10: error: 'struct genlmsghdr' has no member named 'cmd'
         .cmd = CTRL_CMD_GETFAMILY,
          ^~~
../../src/util/virnetdev.c:2981:16: error: 'CTRL_CMD_GETFAMILY' undeclared (first use in this function); did you mean 'U_CHARSET_FAMILY'?
         .cmd = CTRL_CMD_GETFAMILY,
                ^~~~~~~~~~~~~~~~~~
                U_CHARSET_FAMILY
../../src/util/virnetdev.c:2981:16: note: each undeclared identifier is reported only once for each function it appears in
../../src/util/virnetdev.c:2981:16: warning: excess elements in struct initializer
../../src/util/virnetdev.c:2981:16: note: (near initialization for 'gmsgh')
../../src/util/virnetdev.c:2982:10: error: 'struct genlmsghdr' has no member named 'version'
         .version = DEVLINK_GENL_VERSION,
          ^~~~~~~
../../src/util/virnetdev.c:2982:20: warning: excess elements in struct initializer
         .version = DEVLINK_GENL_VERSION,
                    ^~~~~~~~~~~~~~~~~~~~
../../src/util/virnetdev.c:2982:20: note: (near initialization for 'gmsgh')
../../src/util/virnetdev.c:2983:10: error: 'struct genlmsghdr' has no member named 'reserved'
         .reserved = 0,
          ^~~~~~~~
../../src/util/virnetdev.c:2983:21: warning: excess elements in struct initializer
         .reserved = 0,
                     ^
../../src/util/virnetdev.c:2983:21: note: (near initialization for 'gmsgh')
../../src/util/virnetdev.c:2980:23: error: storage size of 'gmsgh' isn't known
     struct genlmsghdr gmsgh = {
                       ^~~~~
../../src/util/virnetdev.c:2985:23: error: 'CTRL_ATTR_MAX' undeclared (first use in this function); did you mean 'DEVLINK_ATTR_MAX'?
     struct nlattr *tb[CTRL_ATTR_MAX + 1] = {NULL, };
                       ^~~~~~~~~~~~~
                       DEVLINK_ATTR_MAX
../../src/util/virnetdev.c:2989:20: warning: implicit declaration of function 'nlmsg_alloc_simple'; did you mean 'g_regex_split_simple'? [-Wimplicit-function-declaration]
     if (!(nl_msg = nlmsg_alloc_simple(GENL_ID_CTRL,
                    ^~~~~~~~~~~~~~~~~~
                    g_regex_split_simple
../../src/util/virnetdev.c:2989:20: warning: nested extern declaration of 'nlmsg_alloc_simple' [-Wnested-externs]
../../src/util/virnetdev.c:2989:39: error: 'GENL_ID_CTRL' undeclared (first use in this function); did you mean 'G_ASCII_CNTRL'?
     if (!(nl_msg = nlmsg_alloc_simple(GENL_ID_CTRL,
                                       ^~~~~~~~~~~~
                                       G_ASCII_CNTRL
../../src/util/virnetdev.c:2990:39: error: 'NLM_F_REQUEST' undeclared (first use in this function)
                                       NLM_F_REQUEST | NLM_F_ACK))) {
                                       ^~~~~~~~~~~~~
../../src/util/virnetdev.c:2990:55: error: 'NLM_F_ACK' undeclared (first use in this function); did you mean 'N_6PACK'?
                                       NLM_F_REQUEST | NLM_F_ACK))) {
                                                       ^~~~~~~~~
                                                       N_6PACK
../../src/util/virnetdev.c:2995:9: warning: implicit declaration of function 'nlmsg_append'; did you mean 'g_list_append'? [-Wimplicit-function-declaration]
     if (nlmsg_append(nl_msg, &gmsgh, sizeof(gmsgh), NLMSG_ALIGNTO) < 0)
         ^~~~~~~~~~~~
         g_list_append
../../src/util/virnetdev.c:2995:9: warning: nested extern declaration of 'nlmsg_append' [-Wnested-externs]
../../src/util/virnetdev.c:2995:53: error: 'NLMSG_ALIGNTO' undeclared (first use in this function); did you mean 'CMSG_ALIGN'?
     if (nlmsg_append(nl_msg, &gmsgh, sizeof(gmsgh), NLMSG_ALIGNTO) < 0)
                                                     ^~~~~~~~~~~~~
                                                     CMSG_ALIGN
../../src/util/virnetdev.c:2998:9: warning: implicit declaration of function 'nla_put_string'; did you mean 'g_hmac_get_string'? [-Wimplicit-function-declaration]
     if (nla_put_string(nl_msg, CTRL_ATTR_FAMILY_NAME, family_name) < 0) {
         ^~~~~~~~~~~~~~
         g_hmac_get_string
../../src/util/virnetdev.c:2998:9: warning: nested extern declaration of 'nla_put_string' [-Wnested-externs]
../../src/util/virnetdev.c:2998:32: error: 'CTRL_ATTR_FAMILY_NAME' undeclared (first use in this function); did you mean 'CTRL_ATTR_MAX'?
     if (nla_put_string(nl_msg, CTRL_ATTR_FAMILY_NAME, family_name) < 0) {
                                ^~~~~~~~~~~~~~~~~~~~~
                                CTRL_ATTR_MAX
../../src/util/virnetdev.c:3004:61: error: 'NETLINK_GENERIC' undeclared (first use in this function); did you mean 'NETLINK_MSG_PUT'?
     if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, 0, NETLINK_GENERIC, 0) < 0)
                                                             ^~~~~~~~~~~~~~~
                                                             NETLINK_MSG_PUT
../../src/util/virnetdev.c:3007:9: warning: implicit declaration of function 'nlmsg_parse'; did you mean 'umsg_parse'? [-Wimplicit-function-declaration]
     if (nlmsg_parse(resp, sizeof(struct nlmsghdr), tb, CTRL_ATTR_MAX, NULL) < 0) {
         ^~~~~~~~~~~
         umsg_parse
../../src/util/virnetdev.c:3007:9: warning: nested extern declaration of 'nlmsg_parse' [-Wnested-externs]
../../src/util/virnetdev.c:3007:34: error: invalid application of 'sizeof' to incomplete type 'struct nlmsghdr'
     if (nlmsg_parse(resp, sizeof(struct nlmsghdr), tb, CTRL_ATTR_MAX, NULL) < 0) {
                                  ^~~~~~
../../src/util/virnetdev.c:3013:12: error: 'CTRL_ATTR_FAMILY_ID' undeclared (first use in this function); did you mean 'CTRL_ATTR_FAMILY_NAME'?
     if (tb[CTRL_ATTR_FAMILY_ID] == NULL) {
            ^~~~~~~~~~~~~~~~~~~
            CTRL_ATTR_FAMILY_NAME
../../src/util/virnetdev.c:3018:31: warning: implicit declaration of function 'RTA_DATA'; did you mean 'NO_DATA'? [-Wimplicit-function-declaration]
     *family_id = *(uint32_t *)RTA_DATA(tb[CTRL_ATTR_FAMILY_ID]);
                               ^~~~~~~~
                               NO_DATA
../../src/util/virnetdev.c:3018:31: warning: nested extern declaration of 'RTA_DATA' [-Wnested-externs]
../../src/util/virnetdev.c:3022:5: warning: implicit declaration of function 'nlmsg_free'; did you mean 'g_list_free'? [-Wimplicit-function-declaration]
     nlmsg_free(nl_msg);
     ^~~~~~~~~~
     g_list_free
../../src/util/virnetdev.c:3022:5: warning: nested extern declaration of 'nlmsg_free' [-Wnested-externs]
../../src/util/virnetdev.c:2985:20: warning: unused variable 'tb' [-Wunused-variable]
     struct nlattr *tb[CTRL_ATTR_MAX + 1] = {NULL, };
                    ^~
../../src/util/virnetdev.c:2980:23: warning: unused variable 'gmsgh' [-Wunused-variable]
     struct genlmsghdr gmsgh = {
                       ^~~~~
../../src/util/virnetdev.c: In function 'virNetDevSwitchdevFeature':
../../src/util/virnetdev.c:3046:12: error: variable 'gmsgh' has initializer but incomplete type
     struct genlmsghdr gmsgh = {
            ^~~~~~~~~~
../../src/util/virnetdev.c:3047:10: error: 'struct genlmsghdr' has no member named 'cmd'
         .cmd = DEVLINK_CMD_ESWITCH_GET,
          ^~~
../../src/util/virnetdev.c:3047:16: warning: excess elements in struct initializer
         .cmd = DEVLINK_CMD_ESWITCH_GET,
                ^~~~~~~~~~~~~~~~~~~~~~~
../../src/util/virnetdev.c:3047:16: note: (near initialization for 'gmsgh')
../../src/util/virnetdev.c:3048:10: error: 'struct genlmsghdr' has no member named 'version'
         .version = DEVLINK_GENL_VERSION,
          ^~~~~~~
../../src/util/virnetdev.c:3048:20: warning: excess elements in struct initializer
         .version = DEVLINK_GENL_VERSION,
                    ^~~~~~~~~~~~~~~~~~~~
../../src/util/virnetdev.c:3048:20: note: (near initialization for 'gmsgh')
../../src/util/virnetdev.c:3049:10: error: 'struct genlmsghdr' has no member named 'reserved'
         .reserved = 0,
          ^~~~~~~~
../../src/util/virnetdev.c:3049:21: warning: excess elements in struct initializer
         .reserved = 0,
                     ^
../../src/util/virnetdev.c:3049:21: note: (near initialization for 'gmsgh')
../../src/util/virnetdev.c:3046:23: error: storage size of 'gmsgh' isn't known
     struct genlmsghdr gmsgh = {
                       ^~~~~
../../src/util/virnetdev.c:3078:39: error: 'NLM_F_REQUEST' undeclared (first use in this function)
                                       NLM_F_REQUEST | NLM_F_ACK))) {
                                       ^~~~~~~~~~~~~
../../src/util/virnetdev.c:3078:55: error: 'NLM_F_ACK' undeclared (first use in this function); did you mean 'N_6PACK'?
                                       NLM_F_REQUEST | NLM_F_ACK))) {
                                                       ^~~~~~~~~
                                                       N_6PACK
../../src/util/virnetdev.c:3083:53: error: 'NLMSG_ALIGNTO' undeclared (first use in this function); did you mean 'CMSG_ALIGN'?
     if (nlmsg_append(nl_msg, &gmsgh, sizeof(gmsgh), NLMSG_ALIGNTO) < 0)
                                                     ^~~~~~~~~~~~~
                                                     CMSG_ALIGN
../../src/util/virnetdev.c:3088:9: warning: implicit declaration of function 'nla_put'; did you mean '_IO_putc'? [-Wimplicit-function-declaration]
     if (nla_put(nl_msg, DEVLINK_ATTR_BUS_NAME, strlen("pci")+1, "pci") < 0 ||
         ^~~~~~~
         _IO_putc
../../src/util/virnetdev.c:3088:9: warning: nested extern declaration of 'nla_put' [-Wnested-externs]
../../src/util/virnetdev.c:3095:61: error: 'NETLINK_GENERIC' undeclared (first use in this function); did you mean 'NETLINK_MSG_PUT'?
     if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, 0, NETLINK_GENERIC, 0) < 0)
                                                             ^~~~~~~~~~~~~~~
                                                             NETLINK_MSG_PUT
../../src/util/virnetdev.c:3098:34: error: invalid application of 'sizeof' to incomplete type 'struct genlmsghdr'
     if (nlmsg_parse(resp, sizeof(struct genlmsghdr), tb, DEVLINK_ATTR_MAX, NULL) < 0) {
                                  ^~~~~~
../../src/util/virnetdev.c:3105:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         *(int *)RTA_DATA(tb[DEVLINK_ATTR_ESWITCH_MODE]) == DEVLINK_ESWITCH_MODE_SWITCHDEV) {
          ^
../../src/util/virnetdev.c:3046:23: warning: unused variable 'gmsgh' [-Wunused-variable]
     struct genlmsghdr gmsgh = {
                       ^~~~~
Makefile:10841: recipe for target 'util/libvirt_util_la-virnetdev.lo' failed
make[6]: *** [util/libvirt_util_la-virnetdev.lo] Error 1
make[6]: Leaving directory '/root/libvirtd/libvirt-6.4.0/build/src'
Makefile:6443: recipe for target 'all' failed
make[5]: *** [all] Error 2
make[5]: Leaving directory '/root/libvirtd/libvirt-6.4.0/build/src'
Makefile:777: recipe for target 'all-recursive' failed
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory '/root/libvirtd/libvirt-6.4.0/build'
Makefile:670: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/root/libvirtd/libvirt-6.4.0/build'
Makefile:1070: recipe for target 'check-am' failed
make[2]: *** [check-am] Error 2
make[2]: Leaving directory '/root/libvirtd/libvirt-6.4.0/build'
Makefile:777: recipe for target 'check-recursive' failed
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory '/root/libvirtd/libvirt-6.4.0/build'
Makefile:1072: recipe for target 'check' failed
make: *** [check] Error 2

标签: libvirt

解决方案


我猜测这可能是由--without-macvtap要配置的 arg 引起的。我希望您触发了#ifdef不正确的检查组合。即使您打算使用桥接网络,让 libvirt 构建 macvtap 支持也没有什么坏处,因此只需删除--without-macvtaparg 作为第一次尝试修复它。


推荐阅读