AppArmor エラー: libvirt の更新バージョン (1.2.12) で lxc を起動した後、「無効な VM 定義」が発生する

AppArmor エラー: libvirt の更新バージョン (1.2.12) で lxc を起動した後、「無効な VM 定義」が発生する

新しいバージョンの libvirtd で LXC を起動しようとしていますが、次のエラーが発生して起動に失敗します。

$ virsh -c lxc: start textlxc
error: Failed to start domain testlxc
error: internal error: cannot load AppArmor profile 'libvirt-dfb2c573-05cb-4ca3-9e46-bea6cebf0f9f'

エラーメッセージログファイル

2015-06-23 12:13:12.306+0000: 14141: error : virCommandWait:2532 : internal error: Child process (/usr/lib/libvirt/virt-aa-helper -p 0 -c -u libvirt-dfb2c573-05cb-4ca3-9e46-bea6cebf0f9f) unexpected exit status 1: virt-aa-helper: error: /proc/meminfo
virt-aa-helper: error: skipped restricted file
virt-aa-helper: error: invalid VM definition

2015-06-23 12:13:12.306+0000: 14141: error : AppArmorGenSecurityLabel:468 : internal error: cannot load AppArmor profile 'libvirt-dfb2c573-05cb-4ca3-9e46-bea6cebf0f9f'

これは私のテストlxc.xmlファイル

<domain type='lxc'>
  <name>testlxc</name>
  <uuid>dfb2c573-05cb-4ca3-9e46-bea6cebf0f9f</uuid>
  <memory unit='KiB'>4048292</memory>
  <currentMemory unit='KiB'>4048292</currentMemory>
  <vcpu placement='static'>2</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64'>exe</type>
    <init>/sbin/init</init>
  </os>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/lib/libvirt/libvirt_lxc</emulator>
    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/var/lib/libvirt/filesystems/testlxc'/>
      <target dir='/'/>
    </filesystem>
    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/var/lib/libvirt/filesystems/testlxc-data'/>
      <target dir='/mnt/data'/>
    </filesystem>
    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/var/run/testlxc/lxc'/>
      <target dir='/mnt/run'/>
    </filesystem>
    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/proc/meminfo'/>
      <target dir='/proc/meminfo'/>
    </filesystem>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target type='lxc' port='0'/>
      <alias name='console0'/>
    </console>
  </devices>
</domain>

実行中の Libvirt のバージョンは 1.2.12 です。以前はバージョン 1.2.2 で lxc を正常に実行していました。

$ libvirtd --version
libvirtd (libvirt) 1.2.12

答え1

問題はユーティリティのドメイン XML 検証にあることを突き止めました。これは、要求に応じて AppArmor プロファイルを生成するユーティリティです。失敗するのは XML の構造ではありませんが、報告されたエラーはこれが原因であることを示しているようです。関数function invirt-aa-helper内の論理検証は、LXC コンテナーでは機能しません。virDomainDefParseXMLdomain_conf.c

私は libvirt コードに十分精通していないため、この共有領域を変更できません。他の何かを壊してしまった可能性がありますが、次のパッチは機能するようです。

if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) {
    /* If the logic here seems fairly arbitrary, that's because it is :)
     * This is duplicating how the code worked before
     * CapabilitiesDomainDataLookup was added. We can simplify this,
     * but it would take a bit of work because the test suite fails
     * in numerous minor ways. */
    bool use_virttype = ((def->os.arch == VIR_ARCH_NONE) ||
        !def->os.machine);
    virCapsDomainDataPtr capsdata = NULL;

読む

if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) {
    /* If the logic here seems fairly arbitrary, that's because it is :)
     * This is duplicating how the code worked before
     * CapabilitiesDomainDataLookup was added. We can simplify this,
     * but it would take a bit of work because the test suite fails
     * in numerous minor ways. */
    bool use_virttype = (def->os.type != VIR_DOMAIN_OS_TYPE_EXE) &&
        ((def->os.arch == VIR_ARCH_NONE) ||
          !def->os.machine);
    virCapsDomainDataPtr capsdata = NULL;

残念ながら、再コンパイルせずにこれを修正する方法は見つかりませんでした。64ビットマシンを使用している場合は、ローカルでビルドしたパッケージを以下からダウンロードできます。このリンク(Microsoft アカウントで失礼します)。

注記: このバグの影響を受けているかどうかを確認するには、コマンドプロンプトで次のコマンドを入力します(このフォーラム投稿):

$ export VM=foo ; virsh -c lxc:// dumpxml $VM |\
   sudo /usr/lib/libvirt/virt-aa-helper -c \
   -u libvirt-`virsh -c lxc:// domuuid $VM`

foo失敗したlxcコンテナの名前はどこにありますか。出力が表示された場合

virt-aa-helper: error: could not parse XML
virt-aa-helper: error: could not get VM definition

おそらく同じバグです。

関連情報