{"id":13200,"date":"2024-04-30T16:13:56","date_gmt":"2024-04-30T08:13:56","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200"},"modified":"2024-08-09T17:08:27","modified_gmt":"2024-08-09T09:08:27","slug":"lxc4-0-0%e6%ba%90%e7%a0%81%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200","title":{"rendered":"lxc4.0.0\u6e90\u7801\u5206\u6790(\u6574\u4f53\u5206\u6790)"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_16 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-1\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#tool%E5%91%BD%E4%BB%A4%E5%90%84%E4%B8%AA%E5%87%BB%E7%A0%B4\" title=\"tool\u547d\u4ee4\u5404\u4e2a\u51fb\u7834\">tool\u547d\u4ee4\u5404\u4e2a\u51fb\u7834<\/a><ul class=\"ez-toc-list-level-2\"><li class=\"ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#%E9%9B%B6%E3%80%81%E9%80%9A%E7%94%A8%E4%BB%A3%E7%A0%81\" title=\"\u96f6\u3001\u901a\u7528\u4ee3\u7801\">\u96f6\u3001\u901a\u7528\u4ee3\u7801<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#1%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%A7%A3%E6%9E%90\" title=\"1.\u547d\u4ee4\u884c\u89e3\u6790\">1.\u547d\u4ee4\u884c\u89e3\u6790<\/a><ul class=\"ez-toc-list-level-4\"><li class=\"ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#%E8%A7%A3%E6%9E%90%E6%96%B9%E6%B3%95\" title=\"\u89e3\u6790\u65b9\u6cd5\">\u89e3\u6790\u65b9\u6cd5<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84\" title=\"\u6570\u636e\u7ed3\u6784\">\u6570\u636e\u7ed3\u6784<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#%E6%97%A5%E5%BF%97%E4%BD%8D%E7%BD%AE%E5%8F%8A%E7%AD%89%E7%BA%A7%E8%AE%BE%E5%AE%9A\" title=\"\u65e5\u5fd7\u4f4d\u7f6e\u53ca\u7b49\u7ea7\u8bbe\u5b9a\">\u65e5\u5fd7\u4f4d\u7f6e\u53ca\u7b49\u7ea7\u8bbe\u5b9a<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#%E8%87%AA%E5%AE%9A%E4%B9%89lxc%E9%85%8D%E7%BD%AE%E9%A1%B9\" title=\"\u81ea\u5b9a\u4e49lxc\u914d\u7f6e\u9879\">\u81ea\u5b9a\u4e49lxc\u914d\u7f6e\u9879<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-8\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#2%E6%97%A5%E5%BF%97%E5%88%9D%E5%A7%8B%E5%8C%96\" title=\"2.\u65e5\u5fd7\u521d\u59cb\u5316\">2.\u65e5\u5fd7\u521d\u59cb\u5316<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-9\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3%E6%97%A5%E5%BF%97%E6%89%93%E5%8D%B0\" title=\"3.\u65e5\u5fd7\u6253\u5370\">3.\u65e5\u5fd7\u6253\u5370<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-10\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#%E4%B8%80%E3%80%81lxc-start\" title=\"\u4e00\u3001lxc-start\">\u4e00\u3001lxc-start<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-11\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#1%E5%88%9B%E5%BB%BA%E5%AE%B9%E5%99%A8\" title=\"1.\u521b\u5efa\u5bb9\u5668\">1.\u521b\u5efa\u5bb9\u5668<\/a><ul class=\"ez-toc-list-level-4\"><li class=\"ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-12\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#%E8%AE%B0%E5%BD%95config_path\" title=\"\u8bb0\u5f55config_path\">\u8bb0\u5f55config_path<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-13\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#lxc_conf%E5%88%9D%E5%A7%8B%E5%8C%96\" title=\"lxc_conf\u521d\u59cb\u5316\">lxc_conf\u521d\u59cb\u5316<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-14\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#%E5%87%BD%E6%95%B0%E6%8C%87%E9%92%88%E8%B5%8B%E5%80%BC\" title=\"\u51fd\u6570\u6307\u9488\u8d4b\u503c\">\u51fd\u6570\u6307\u9488\u8d4b\u503c<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-15\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#2%E6%A0%A1%E9%AA%8C%E5%AE%B9%E5%99%A8\" title=\"2.\u6821\u9a8c\u5bb9\u5668\">2.\u6821\u9a8c\u5bb9\u5668<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-16\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3%E8%BF%90%E8%A1%8C%E5%AE%B9%E5%99%A8\" title=\"3.\u8fd0\u884c\u5bb9\u5668\">3.\u8fd0\u884c\u5bb9\u5668<\/a><ul class=\"ez-toc-list-level-4\"><li class=\"ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-17\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-1%EF%BC%89%E5%88%9B%E5%BB%BA%E5%AE%B9%E5%99%A8%E8%BF%9B%E7%A8%8B\" title=\"3-1\uff09\u521b\u5efa\u5bb9\u5668\u8fdb\u7a0b\">3-1\uff09\u521b\u5efa\u5bb9\u5668\u8fdb\u7a0b<\/a><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-18\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-1-1%EF%BC%89%E4%B8%80%E4%BA%9B%E5%88%9D%E5%A7%8B%E5%8C%96%E5%B7%A5%E4%BD%9C\" title=\"3-1-1\uff09\u4e00\u4e9b\u521d\u59cb\u5316\u5de5\u4f5c\">3-1-1\uff09\u4e00\u4e9b\u521d\u59cb\u5316\u5de5\u4f5c<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-19\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-1-2%EF%BC%89%E5%88%9B%E5%BB%BA%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E5%AE%B9%E5%99%A8%E8%BF%9B%E7%A8%8B\" title=\"3-1-2\uff09\u521b\u5efa\u5b88\u62a4\u8fdb\u7a0b(\u5bb9\u5668\u8fdb\u7a0b)\">3-1-2\uff09\u521b\u5efa\u5b88\u62a4\u8fdb\u7a0b(\u5bb9\u5668\u8fdb\u7a0b)<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-20\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-2%EF%BC%89%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E5%AE%B9%E5%99%A8%E8%BF%9B%E7%A8%8Bstart%E9%80%BB%E8%BE%91\" title=\"3-2\uff09\u5b88\u62a4\u8fdb\u7a0b(\u5bb9\u5668\u8fdb\u7a0b)start\u903b\u8f91\">3-2\uff09\u5b88\u62a4\u8fdb\u7a0b(\u5bb9\u5668\u8fdb\u7a0b)start\u903b\u8f91<\/a><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-21\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-2-1%EF%BC%89%E5%88%9D%E5%A7%8B%E5%8C%96%E5%AE%B9%E5%99%A8%EF%BC%88%E4%B8%BBCGROUP%E9%80%BB%E8%BE%91%E5%A4%84%E7%90%86%EF%BC%89\" title=\"3-2-1\uff09\u521d\u59cb\u5316\u5bb9\u5668\uff08\u4e3bCGROUP\u903b\u8f91\u5904\u7406\uff09\">3-2-1\uff09\u521d\u59cb\u5316\u5bb9\u5668\uff08\u4e3bCGROUP\u903b\u8f91\u5904\u7406\uff09<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-22\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-2-1-0%EF%BC%89lxc_terminal_setup\" title=\"3-2-1-0\uff09lxc_terminal_setup\">3-2-1-0\uff09lxc_terminal_setup<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-23\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-2-1-1%EF%BC%89%E5%88%9D%E5%A7%8B%E5%8C%96cgroup\" title=\"3-2-1-1\uff09\u521d\u59cb\u5316cgroup\">3-2-1-1\uff09\u521d\u59cb\u5316cgroup<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-24\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-2-1-2%EF%BC%89%E5%88%9D%E5%A7%8B%E5%8C%96%E5%AE%89%E5%85%A8%E6%A1%86%E6%9E%B6\" title=\"3-2-1-2\uff09\u521d\u59cb\u5316\u5b89\u5168\u6846\u67b6\">3-2-1-2\uff09\u521d\u59cb\u5316\u5b89\u5168\u6846\u67b6<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-25\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-2-1-3%EF%BC%89%E8%AE%B0%E5%BD%95%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8Bstatus%E6%96%87%E4%BB%B6fd\" title=\"3-2-1-3\uff09\u8bb0\u5f55\u5b88\u62a4\u8fdb\u7a0bstatus\u6587\u4ef6fd\">3-2-1-3\uff09\u8bb0\u5f55\u5b88\u62a4\u8fdb\u7a0bstatus\u6587\u4ef6fd<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-26\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#i\" title=\"-------------------------------------------------------------------------------------------------\">-------------------------------------------------------------------------------------------------<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-27\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#i-2\" title=\"-------------------------------------------------------------------------------------------------\">-------------------------------------------------------------------------------------------------<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-28\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-2-2%EF%BC%89%E5%AD%B5%E5%8C%96%E5%AE%B9%E5%99%A8%EF%BC%88%E4%B8%BBNAMESPACE%E9%80%BB%E8%BE%91%E5%A4%84%E7%90%86%EF%BC%89\" title=\"3-2-2\uff09\u5b75\u5316\u5bb9\u5668\uff08\u4e3bNAMESPACE\u903b\u8f91\u5904\u7406\uff09\">3-2-2\uff09\u5b75\u5316\u5bb9\u5668\uff08\u4e3bNAMESPACE\u903b\u8f91\u5904\u7406\uff09<\/a><ul class=\"ez-toc-list-level-6\"><li class=\"ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-29\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-2-2-1%EF%BC%89monitor%E8%BF%9B%E7%A8%8B%E7%BB%A7%E7%BB%AD%E6%89%A7%E8%A1%8C\" title=\"3-2-2-1\uff09monitor\u8fdb\u7a0b\u7ee7\u7eed\u6267\u884c\">3-2-2-1\uff09monitor\u8fdb\u7a0b\u7ee7\u7eed\u6267\u884c<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-30\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-2-2-2%EF%BC%89payload%E8%BF%9B%E7%A8%8B%E5%B9%B2%E4%BA%86%E4%BA%9B%E5%95%A5\" title=\"3-2-2-2\uff09payload\u8fdb\u7a0b\u5e72\u4e86\u4e9b\u5565\">3-2-2-2\uff09payload\u8fdb\u7a0b\u5e72\u4e86\u4e9b\u5565<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-31\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#3-2-3_%E5%AE%B9%E5%99%A8%E7%9B%91%E5%90%AC\" title=\"3-2-3) \u5bb9\u5668\u76d1\u542c\">3-2-3) \u5bb9\u5668\u76d1\u542c<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-32\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=13200\/#%E4%BA%8C%E3%80%81lxc-attach\" title=\"\u4e8c\u3001lxc-attach\">\u4e8c\u3001lxc-attach<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"tool%E5%91%BD%E4%BB%A4%E5%90%84%E4%B8%AA%E5%87%BB%E7%A0%B4\"><\/span>tool\u547d\u4ee4\u5404\u4e2a\u51fb\u7834<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<h2><span class=\"ez-toc-section\" id=\"%E9%9B%B6%E3%80%81%E9%80%9A%E7%94%A8%E4%BB%A3%E7%A0%81\"><\/span>\u96f6\u3001\u901a\u7528\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"1%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%A7%A3%E6%9E%90\"><\/span>1.\u547d\u4ee4\u884c\u89e3\u6790<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E6%9E%90%E6%96%B9%E6%B3%95\"><\/span>\u89e3\u6790\u65b9\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>lxc_arguments_parse\uff1a\u6ce8\u610f\u90e8\u5206\u53c2\u6570\u662f\u901a\u8fc7\u5404\u4e2a\u547d\u4ee4\u5de5\u5177\u6e90\u7801\u4e2d\u7684<code>my_parser(struct lxc_arguments *args, int c, char *arg)<\/code>\u65b9\u6cd5\u89e3\u6790\u7684<br \/>\nconfile.c\u4e2d\u5c01\u88c5\u4e86\u914d\u7f6e\u9879\u7684set\/get\u65b9\u6cd5<\/p>\n<p>lxc-start\u547d\u4ee4\u91cd\u8981\u7684\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>1)lxcpath:\u5373\u5bb9\u5668\u914d\u7f6e\u6587\u4ef6\u7684\u6839\u76ee\u5f55<\/li>\n<\/ul>\n<p>lxcpath\u53ef\u4ee5\u901a\u8fc7-P\u53c2\u6570\u6307\u5b9a\uff0c\u4e00\u822c\u5728\u7f16\u8bd1\u65f6\u901a\u8fc7configure\u811a\u672c\u7684<code>--with-config-path<\/code>\u53c2\u6570\u6307\u5b9a\uff0c\u6700\u7ec8\u5728\u7f16\u8bd1\u65f6\u901a\u8fc7\u5b8f\u5b9a\u4e49<code>-DLXCPATH<\/code>\u4f20\u9012\u7ed9\u76ee\u6807\u6587\u4ef6\u3002\u89c1lxc_arguments_parse\u65b9\u6cd5\uff0c\u5982\u679clxcpath\u5728\u7f16\u8bd1\u65f6\u6307\u5b9a\uff0c\u5219\u89e3\u6790\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-c\">    \/* If no lxcpaths were given, use default *\/\n    if (!args-&gt;lxcpath_cnt) {\n        ret = lxc_arguments_lxcpath_add(\n            args, lxc_get_global_config_item(&quot;lxc.lxcpath&quot;));\n        if (ret &lt; 0)\n            return ret;\n    }\n\n\/\/lxc_get_global_config_item\u4f4d\u4e8elxccontainer.c\u4e2d\n\/\/lxc_get_global_config_item\u518d\u8c03\u7528initutils.c\u4e2d\u7684lxc_global_config_value\u4ece\u5b8f\u4e2d\u83b7\u53d6lxcpath\u53c2\u6570<\/code><\/pre>\n<ul>\n<li>2)args-&gt;argv:\u5373\u5bb9\u5668\u8981\u6267\u884c\u7684\u76ee\u6807\u7a0b\u5e8f<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84\"><\/span>\u6570\u636e\u7ed3\u6784<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>lxc_arguments<br \/>\n\u2192argv:\u5b58\u50a8\u547d\u4ee4\u7684\u542f\u52a8\u53c2\u6570\uff0c\u5982lxc-start -- \/init\uff0c\u5373\u662f\/init.<\/p>\n<h4><span class=\"ez-toc-section\" id=\"%E6%97%A5%E5%BF%97%E4%BD%8D%E7%BD%AE%E5%8F%8A%E7%AD%89%E7%BA%A7%E8%AE%BE%E5%AE%9A\"><\/span>\u65e5\u5fd7\u4f4d\u7f6e\u53ca\u7b49\u7ea7\u8bbe\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><code>--logfile .\/lxc_attach.log --logpriority trace<\/code><\/p>\n<h4><span class=\"ez-toc-section\" id=\"%E8%87%AA%E5%AE%9A%E4%B9%89lxc%E9%85%8D%E7%BD%AE%E9%A1%B9\"><\/span>\u81ea\u5b9a\u4e49lxc\u914d\u7f6e\u9879<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><a href=\"https:\/\/www.cnblogs.com\/lisperl\/archive\/2012\/04\/16\/2451215.html\">https:\/\/www.cnblogs.com\/lisperl\/archive\/2012\/04\/16\/2451215.html<\/a><br \/>\n\u5bf9\u4e8elxc-start\u547d\u4ee4\uff0c\u914d\u7f6e\u9879\u662f\u901a\u8fc7-s\u53c2\u6570\u4ee5KEY=VALUE\u7684\u5f62\u5f0f\u6307\u5b9a\u7684\uff0c\u5728my_parser\u65b9\u6cd5\u4e2d\u5b9e\u73b0\u3002<\/p>\n<pre><code class=\"language-c\">    case &#039;s&#039;:\n        return lxc_config_define_add(&amp;defines, arg);<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2%E6%97%A5%E5%BF%97%E5%88%9D%E5%A7%8B%E5%8C%96\"><\/span>2.\u65e5\u5fd7\u521d\u59cb\u5316<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>lxc_log_init<br \/>\n\u53ef\u77e5\u65e5\u5fd7\u7684\u9ed8\u8ba4\u7b49\u7ea7\u4e3aERROR<\/p>\n<pre><code class=\"language-cpp\">int lxc_log_init(struct lxc_log *log)\n{\n    int ret;\n    int lxc_priority = LXC_LOG_LEVEL_ERROR;\n    ...\n    if (log-&gt;level)\n        lxc_priority = lxc_log_priority_to_int(log-&gt;level);\n}<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"3%E6%97%A5%E5%BF%97%E6%89%93%E5%8D%B0\"><\/span>3.\u65e5\u5fd7\u6253\u5370<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u770b\u6765\u4f5c\u8005\u5bf9\u5b8f\u5b9a\u4e49\u5c61\u8bd5\u4e0d\u723d<\/p>\n<pre><code class=\"language-c\">#define INFO(format, ...) do {                      \\\n    struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;      \\\n    LXC_INFO(&amp;locinfo, format, ##__VA_ARGS__);          \\\n} while (0)\n\n__lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo,    \\\n                       const char* format, ...) <\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E4%B8%80%E3%80%81lxc-start\"><\/span>\u4e00\u3001lxc-start<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5bf9\u4e8elxc-start\u5728\u547d\u4ee4\u884c\u89e3\u6790\u4e4b\u524d\u6709\u4e00\u6bb5\u521d\u59cb\u5316\u914d\u7f6e\u6587\u4ef6\u6570\u636e\u7ed3\u6784\u7684\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-c\">static struct lxc_list defines;\n...\n\/\/\u521d\u59cb\u5316\u53cc\u5411\u94fe\u8868\nlxc_list_init(&amp;defines);<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"1%E5%88%9B%E5%BB%BA%E5%AE%B9%E5%99%A8\"><\/span>1.\u521b\u5efa\u5bb9\u5668<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u8c03\u7528lxccontainer.c\u7684lxc_container_new\u65b9\u6cd5<\/p>\n<h4><span class=\"ez-toc-section\" id=\"%E8%AE%B0%E5%BD%95config_path\"><\/span>\u8bb0\u5f55config_path<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>c-&gt;config_path = strdup(configpath);<\/p>\n<p>set_config_filename\uff1a\u5c06config\u6587\u4ef6\u8def\u5f84\u4fdd\u5b58\u5230c-&gt;configfile<\/p>\n<h4><span class=\"ez-toc-section\" id=\"lxc_conf%E5%88%9D%E5%A7%8B%E5%8C%96\"><\/span>lxc_conf\u521d\u59cb\u5316<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-c\">    if (file_exists(c-&gt;configfile) &amp;&amp; !lxcapi_load_config(c, NULL)) {\n        fprintf(stderr, &quot;Failed to load config for %s\\n&quot;, name);\n        goto err;\n    }\n\n\/\/\u6ce8\u610flxcapi_load_config\u8fd9\u4e2a\u65b9\u6cd5\uff0c\u662f\u5b8f\u5b9a\u4e49\u7684\u51fd\u6570\u3002\nWRAP_API_1(bool, lxcapi_load_config, const char *)  \n\n#define WRAP_API_1(rettype, fnname, t1)                 \\\nstatic rettype fnname(struct lxc_container *c, t1 a1)           \\\n{                                   \\\n    rettype ret;                            \\\n    bool reset_config = false;                  \\\n                                    \\\n    if (!current_config &amp;&amp; c &amp;&amp; c-&gt;lxc_conf) {           \\\n        current_config = c-&gt;lxc_conf;                \\\n        reset_config = true;                    \\\n    }                               \\\n                                    \\\n    ret = do_##fnname(c, a1);                   \\\n    if (reset_config)                       \\\n        current_config = NULL;                  \\\n                                    \\\n    return ret;                         \\\n}\n\n\/\/lxcapi_load_config\u6700\u540e\u4f1a\u8c03\u7528do_lxcapi_load_config\u65b9\u6cd5\nstatic bool load_config_locked(struct lxc_container *c, const char *fname)\n{\n    if (!c-&gt;lxc_conf)\n        c-&gt;lxc_conf = lxc_conf_init();\n\n    if (!c-&gt;lxc_conf)\n        return false;\n\n    \/\/\u5c06config\u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u9879\u8bfb\u53d6\u5230c-&gt;lxc_conf\u4e2d\n    if (lxc_config_read(fname, c-&gt;lxc_conf, false) != 0)\n        return false;\n\n    c-&gt;lxc_conf-&gt;name = c-&gt;name;\n    return true;\n}\n\n\/\/lxc_config_read\u4f1a\u8c03\u7528parse_line\u65b9\u6cd5\nstatic int parse_line(char *buffer, void *data){\n...\n\/\/\u8fd4\u56deconfig_jump_table\u6570\u7ec4\u4e2d\u7684lxc_config_t\u7ed3\u6784\u4f53\uff0c\u5b9a\u4e49\u4e86\u5404\u4e2a\u53c2\u6570\u7684get\/set\/clr\u65b9\u6cd5\nconfig = lxc_get_config(key);\n    if (!config) {\n        ERROR(&quot;Unknown configuration key \\&quot;%s\\&quot;&quot;, key);\n        goto on_error;\n    }\n    ret = config-&gt;set(key, value, plc-&gt;conf, NULL);\n...\n}\n\nstruct lxc_config_t {\n    char *name;\n    config_set_cb set;\n    config_get_cb get;\n    config_clr_cb clr;\n};\n<\/code><\/pre>\n<ul>\n<li>lxc.net.N.xx<br \/>\n\u6ce8\u610f\u7f51\u7edc\u914d\u7f6e\u53ef\u80fd\u4f1a\u6709\u591a\u7ec4\uff0c\u901a\u8fc7lxc_network_add\u65b9\u6cd5\u8ffd\u52a0\u3002<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"%E5%87%BD%E6%95%B0%E6%8C%87%E9%92%88%E8%B5%8B%E5%80%BC\"><\/span>\u51fd\u6570\u6307\u9488\u8d4b\u503c<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-bash\">...\nc-&gt;start = lxcapi_start;\n\n\/\/\u9ed8\u8ba4\u4ee5\u5b88\u62a4\u8fdb\u7a0b\u7684\u65b9\u5f0f\u521b\u5efa\u5bb9\u5668\nc-&gt;daemonize = true;\n...<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2%E6%A0%A1%E9%AA%8C%E5%AE%B9%E5%99%A8\"><\/span>2.\u6821\u9a8c\u5bb9\u5668<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u5982\u5bb9\u5668\u6709\u6ca1\u6709\u5728\u8fd0\u884c\u7b49<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3%E8%BF%90%E8%A1%8C%E5%AE%B9%E5%99%A8\"><\/span>3.\u8fd0\u884c\u5bb9\u5668<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u8c03\u7528\u5bb9\u5668lxccontainer.c\u7684start\u65b9\u6cd5\uff0c\u4e5f\u5c31\u662flxcapi_start\u65b9\u6cd5,\u63a5\u7740\u8c03\u7528\uff1a<br \/>\n\u2192do_lxcapi_start<\/p>\n<h4><span class=\"ez-toc-section\" id=\"3-1%EF%BC%89%E5%88%9B%E5%BB%BA%E5%AE%B9%E5%99%A8%E8%BF%9B%E7%A8%8B\"><\/span>3-1\uff09\u521b\u5efa\u5bb9\u5668\u8fdb\u7a0b<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<h5><span class=\"ez-toc-section\" id=\"3-1-1%EF%BC%89%E4%B8%80%E4%BA%9B%E5%88%9D%E5%A7%8B%E5%8C%96%E5%B7%A5%E4%BD%9C\"><\/span>3-1-1\uff09\u4e00\u4e9b\u521d\u59cb\u5316\u5de5\u4f5c<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u2192\u2192ongoing_create<br \/>\n\u2192\u2192container_mem_lock<br \/>\n\u2192\u2192lxc_init_handler\uff08\u91cd\u8981\uff09<\/p>\n<pre><code class=\"language-cpp\">\u521b\u5efa\u5e76\u521d\u59cb\u5316lxc_handler\u7ed3\u6784\u4f53\n\/\/\u8bb0\u5f55lxc-start\u547d\u4ee4\u8fdb\u7a0b\uff0ctransient\u4e34\u65f6\u7684\u610f\u601d\u3002\u56e0\u4e3a\u6700\u7ec8lxc-start\u8fdb\u7a0bfork\u51fa\u5bb9\u5668\u7684\u5b88\u62a4\u8fdb\u7a0b\u4e4b\u540e\u662f\u4f1a\u88ab\u6740\u6b7b\u7684\u3002\nhandler-&gt;transient_pid = lxc_raw_getpid();\n\/\/\u521b\u5efa\u4e00\u5bf9\u76f8\u4e92\u901a\u4fe1\u7684socket\uff0c\u5b58\u50a8\u5728lxc_handler-&gt;state_socket_pair\u7ed3\u6784\u4f53\u4e2d\uff0c\u5bb9\u5668\u8fdb\u7a0b\u5c31\u662f\u901a\u8fc7\u8fd9\u5bf9socket\u544a\u77e5lxc-start\u8fdb\u7a0b\u5bb9\u5668\u72b6\u6001\u7684\u3002\nsocketpair\n\/\/Created abstract unix socket &quot;\/data\/media\/build_lxc\/containers\/android1\/command&quot;\nlxc_cmd_init<\/code><\/pre>\n<p>\u62ff\u5230lxc-start\u7684\u542f\u52a8\u7a0b\u5e8f<\/p>\n<p>\u2192\u2192container_mem_unlock<\/p>\n<h5><span class=\"ez-toc-section\" id=\"3-1-2%EF%BC%89%E5%88%9B%E5%BB%BA%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E5%AE%B9%E5%99%A8%E8%BF%9B%E7%A8%8B\"><\/span>3-1-2\uff09\u521b\u5efa\u5b88\u62a4\u8fdb\u7a0b(\u5bb9\u5668\u8fdb\u7a0b)<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u2192\u2192pid_first = fork();<\/p>\n<pre><code class=\"language-cpp\">\u2192\/* first parent *\/ (\u7236\u8fdb\u7a0b\uff0c\u5373lxc-start\u547d\u4ee4\u8fdb\u7a0b\u3002)\n\n\/* Set to NULL because we don&#039;t want father unlink\n * the PID file, child will do the free and unlink.\n*\/\nc-&gt;pidfile = NULL;\n\n\/*\nWait for container to tell us whether it started successfully.\n*\/\n\/\/lxc-start\u8fdb\u7a0b\u7b49\u5f85pid_first fork\u5b8cpid_second\u8fdb\u7a0b\u5c31\u7ed3\u675f\u4e86\nstarted = wait_on_daemonized_start(handler, pid_first);\n\n\/\/lxc-start\u8fdb\u7a0b\u81f3\u6b64\u5c31\u7ed3\u675f\u4e86\nreturn started;\n\u2192\/* first child *\/ (\u5b50\u8fdb\u7a0b)\n\/\/\u8bbe\u7f6e\u5b50\u8fdb\u7a0b\u7684\u8fdb\u7a0b\u540d (\u5931\u8d25\u4e86\uff0c\u5f85\u89e3\u51b3\u3002\u6d89\u53ca\u975e\u5e38\u5e95\u5c42\u7684\u7cfb\u7edf\u8c03\u7528)\nsetproctitle\n<\/code><\/pre>\n<p>\u2192\u2192pid_second = fork();<\/p>\n<pre><code class=\"language-cpp\">\/* second parent *\/\n\u91ca\u653e\u5185\u5b58\u5e76\u9000\u51fa\u5f53\u524d\u8fdb\u7a0b\n\n\/* second child *\/\n\/\/\u4fee\u6539\u8fdb\u7a0b\u7684\u5de5\u4f5c\u76ee\u5f55\u4e3a\/\nchdir \n\n\/\/\u5173\u95ed\u5b88\u62a4\u8fdb\u7a0bfd\uff0c\u5e76\u5ffd\u7565\u90e8\u5206fd\u3002\nlxc_check_inherited\n\n\/* redirect std{in,out,err} to \/dev\/null *\/\nnull_stdfds();\n\n\/* become session leader *\/\nret = setsid();\n<\/code><\/pre>\n<blockquote>\n<p>\u6ce8\u610f\u81ea\u6b64\u5f00\u59cb\uff0c\u90fd\u662f\u5b88\u62a4\u8fdb\u7a0b\u5728\u6267\u884c!!!!!<\/p>\n<p>\u867d\u7136ps | grep lxc\u4ecd\u7136\u663e\u793alxc-start\u8fdb\u7a0b\uff0c\u4f46\u662f\u8fd9\u4e2a\u540d\u5b57\u4e3alxc-start\u7684\u8fdb\u7a0b\u5b9e\u9645\u4e3a\u7b2c\u4e8c\u4e2afork\u7684\u5b88\u62a4\u8fdb\u7a0b\u3002\uff08\u6b63\u662f\u56e0\u4e3a\u66f4\u6539\u5b50\u8fdb\u7a0bsetproctitle\u65b9\u6cd5\u6267\u884c\u5931\u8d25\u4e86\uff0c\u624d\u4f1a\u6709\u8fd9\u4e2a\u8bef\u89e3\uff01\uff09<\/p>\n<\/blockquote>\n<pre><code class=\"language-cpp\">\/\/lxc-start\u901a\u8fc7-p\u53c2\u6570\u6307\u5b9a\u4e86pid\u5199\u5165\u8def\u5f84\uff0c\u5c31\u8bb0\u5f55\u5b88\u62a4\u8fdb\u7a0b\u7684pid\u3002\nif (c-&gt;pidfile) {\n...\n}<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"3-2%EF%BC%89%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E5%AE%B9%E5%99%A8%E8%BF%9B%E7%A8%8Bstart%E9%80%BB%E8%BE%91\"><\/span>3-2\uff09\u5b88\u62a4\u8fdb\u7a0b(\u5bb9\u5668\u8fdb\u7a0b)start\u903b\u8f91<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u2192\u2192lxc_start<br \/>\n\u2192\u2192\u2192<code>__lxc_start<\/code><\/p>\n<h5><span class=\"ez-toc-section\" id=\"3-2-1%EF%BC%89%E5%88%9D%E5%A7%8B%E5%8C%96%E5%AE%B9%E5%99%A8%EF%BC%88%E4%B8%BBCGROUP%E9%80%BB%E8%BE%91%E5%A4%84%E7%90%86%EF%BC%89\"><\/span>3-2-1\uff09\u521d\u59cb\u5316\u5bb9\u5668\uff08\u4e3bCGROUP\u903b\u8f91\u5904\u7406\uff09<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u2192\u2192\u2192\u2192\u91cd\u8981\u65b9\u6cd51\uff1a<code>lxc_init\uff08\u521d\u59cb\u5316\u5bb9\u5668\uff09<\/code><\/p>\n<pre><code class=\"language-cpp\">\/\/\u83b7\u53d6\u5b88\u62a4\u8fdb\u7a0b\u7684\u8fdb\u7a0bid\nhandler-&gt;monitor_pid = lxc_raw_getpid();\n\n\/\/\u8bfb\u53d6\u5b88\u62a4\u8fdb\u7a0b\u7684status\u72b6\u6001\nstatus_fd = open(&quot;\/proc\/self\/status&quot;, O_RDONLY | O_CLOEXEC);\n\n\/\/\u521d\u59cb\u5316\u5b89\u5168\u6846\u67b6\nlsm_init\n\n\/\/\u8bbe\u7f6e\u4e91\u673a\u72b6\u6001\u4e3aSTARTING\uff0c\u5c31\u662f\u5229\u7528\u524d\u9762\u7684pair socket\u6765\u5b9e\u73b0\u8fdb\u7a0b\u901a\u8baf\u3002\nret = lxc_set_state(name, handler, STARTING);\n\n\/\/\u8bbe\u7f6e\u5404\u79cdLXC_XX\u73af\u5883\u53d8\u91cf\n...\n\n\/\/\u8fd0\u884cpre-start\u7684hook\u811a\u672c\nret = run_lxc_hooks(name, &quot;pre-start&quot;, conf, NULL);\n\n\/\/\u5229\u7528signalfd\u51fd\u6570\u521b\u5efa\u4fe1\u53f7\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u540e\u9762lxc_poll\u65b9\u6cd5\u91cc\u4f1a\u7528\u5230\u3002\nsetup_signal_fd\n\n\/\/\u9ed8\u8ba4\u914d\u7f6e\u4e3a\u7a7a\uff0cdo nothing\nlxc_terminal_setup\ngoto 3-2-1-0\uff09\n\n\/\/\u9ed8\u8ba4\u914d\u7f6e\u4e3a\u7a7a\uff0cdo nothing\nlxc_terminal_map_ids<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"3-2-1-0%EF%BC%89lxc_terminal_setup\"><\/span>3-2-1-0\uff09lxc_terminal_setup<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u2192lxc_terminal_create<br \/>\na.\u5229\u7528openpty\u51fd\u6570\u521b\u5efa\u4f2a\u7ec8\u7aef\u5bf9<br \/>\n<code>ret = openpty(&amp;terminal-&gt;master, &amp;terminal-&gt;slave, NULL, NULL, NULL);<\/code><\/p>\n<p>b.\u83b7\u53d6\u4ece\u8bbe\u5907\u7684\u8bbe\u5907\u540d\u79f0<br \/>\n<code>ret = ttyname_r(terminal-&gt;slave, terminal-&gt;name, sizeof(terminal-&gt;name));<\/code><br \/>\n\u83b7\u53d6\u540e\u4f1a\u5b58\u50a8\u5728lxc_conf\u7684console\u53d8\u91cf\u4e2d<\/p>\n<p>c.\u5173\u95ed\u4f2a\u7ec8\u7aef\u5bf9<\/p>\n<p>\/\/\uff1f<br \/>\n<code>lxc_terminal_peer_default<\/code><br \/>\ngoto on_success<\/p>\n<p>\u2192lxc_terminal_create_ringbuf<br \/>\n\u9ed8\u8ba4\u662f\u6ca1\u6709buffer\u7684<\/p>\n<h5><span class=\"ez-toc-section\" id=\"3-2-1-1%EF%BC%89%E5%88%9D%E5%A7%8B%E5%8C%96cgroup\"><\/span>3-2-1-1\uff09\u521d\u59cb\u5316cgroup<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u2192\u2192\u2192\u2192\u2192<code>cgroup_init<\/code>\uff08cgroup.c\uff09<br \/>\n\u51fd\u6570\u8fd4\u56decgroup_ops\u7ed3\u6784\u4f53\u5b58\u50a8\u4e8ehandler-&gt;cgroup_ops\uff0c\u540e\u9762\u4f1a\u7528\u5230\u3002\u6ce8\u610fcgroup_ops\u7ed3\u6784\u4f53\u5f88\u91cd\u8981\uff0c\u5b58\u50a8cgroup\u76f8\u5173\u7684\u5404\u79cd\u4fe1\u606f\u548c\u64cd\u4f5c\u51fd\u6570\u3002<br \/>\n<code>handler-&gt;cgroup_ops = cgroup_init(handler-&gt;conf);<\/code><\/p>\n<p>\u2192\u2192\u2192\u2192\u2192\u2192<strong>cgfsng_ops_init<\/strong>\uff08cgfsng.c\uff09<\/p>\n<p>\u4f7f\u7528\u52a8\u6001\u5185\u5b58\u521b\u5efacgfsng_ops\u7ed3\u6784\u4f53<\/p>\n<p><strong>-----TAG_A-START-----<\/strong><br \/>\n\u2192\u2192\u2192\u2192\u2192\u2192\u2192cg_init<\/p>\n<ul>\n<li>TAG_A-1) CGROUP2\u521d\u59cb\u5316<\/li>\n<\/ul>\n<p>\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u2192cg_unified_init \uff08<strong>v2\u8d70\u6b64\u65b9\u6cd5<\/strong>\uff09<br \/>\n\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u2192unified_cgroup_hierarchy \uff08\u5224\u65ad\u662f\u5426\u662funified\u6a21\u5f0f\uff0c\u4e5f\u5c31\u662fcgroup2\uff09<br \/>\n\u4f1a\u68c0\u67e5DEFAULT_CGROUP_MOUNTPOINT\u4e5f\u5c31\u662f<code>\/sys\/fs\/cgroup<\/code>\u662f\u4ec0\u4e48\u7c7b\u578b\u7684cgroup<\/p>\n<ul>\n<li>TAG_A-2) CGROUP1\u521d\u59cb\u5316<\/li>\n<\/ul>\n<p>\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u2192cg_hybrid_init \uff08<strong>\u975ev2\u624d\u4f1a\u8d70\u6b64\u65b9\u6cd5<\/strong>\uff09<br \/>\n\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u2192get_existing_subsystems \uff08\u83b7\u53d6\u5b58\u5728\u7684cgroup\u5b50\u7cfb\u7edf\uff09<br \/>\n\u89e3\u6790<code>\/proc\/self\/cgroup<\/code>\u6587\u4ef6<br \/>\n\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u2192lxc_cgfsng_print_basecg_debuginfo \uff08\u6253\u5370cgroup\u5b50\u7cfb\u7edf\u57fa\u672c\u4fe1\u606f\uff09<br \/>\n\u7ed3\u679c\u4e3a\uff1a<\/p>\n<pre><code class=\"language-bash\">6:schedtune:\/\n5:cpuset:\/\n4:cpuacct:\/\n3:cpu:\/\n2:blkio:\/\n1:memory:\/\n0::\/<\/code><\/pre>\n<p>\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u2192\u89e3\u6790<code>\/proc\/self\/mountinfo<\/code>\u6587\u4ef6<br \/>\n\u4f1a\u8fc7\u6ee4\u6389cgroup2\u7c7b\u578b<br \/>\ncg_hybrid_get_controllers \uff08\u5224\u65adhierarchy\u662f\u5426\u5728DEFAULT_CGROUP_MOUNTPOINT\u4e0b\uff09<br \/>\n\/\/TODO\uff0c\u672a\u5b8c\u5f85\u7eed<br \/>\n<strong>-----TAG_A-END-----<\/strong><\/p>\n<p>cgfsng_ops\u7ed3\u6784\u4f53\u51fd\u6570\u6307\u9488\u8d4b\u503c<\/p>\n<h5><span class=\"ez-toc-section\" id=\"3-2-1-2%EF%BC%89%E5%88%9D%E5%A7%8B%E5%8C%96%E5%AE%89%E5%85%A8%E6%A1%86%E6%9E%B6\"><\/span>3-2-1-2\uff09\u521d\u59cb\u5316\u5b89\u5168\u6846\u67b6<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<pre><code class=\"language-c\">ret = lxc_read_seccomp_config(conf);\nret = lsm_process_prepare(conf, handler-&gt;lxcpath);<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"3-2-1-3%EF%BC%89%E8%AE%B0%E5%BD%95%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8Bstatus%E6%96%87%E4%BB%B6fd\"><\/span>3-2-1-3\uff09\u8bb0\u5f55\u5b88\u62a4\u8fdb\u7a0bstatus\u6587\u4ef6fd<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p><code>handler-&gt;monitor_status_fd = move_fd(status_fd);<\/code><br \/>\n\u8bb0\u5f55\/proc\/self\/status\u6587\u4ef6\u7684fd\u503c\uff0c\u540e\u9762\u4f1a\u7528\u5230\u3002<\/p>\n<h5><span class=\"ez-toc-section\" id=\"i\"><\/span><code>-------------------------------------------------------------------------------------------------<\/code><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>lxc_init\u65b9\u6cd5\u4e4b\u540e\u4f1a\u8c03\u7528cgroup_ops\u7684monitor\u76f8\u5173\u65b9\u6cd5\uff1a<br \/>\n1) monitor_create<br \/>\n\u521b\u5efamonitor group\u3002\u5047\u5982\u5bb9\u5668name\u4e3aandroid1,\u5219\u6b64group\u540d\u79f0\u4e3alxc.monitor.android1.<\/p>\n<p>\u5177\u4f53\u89c1create_cgroup_tree\u65b9\u6cd5\uff1a<\/p>\n<pre><code class=\"language-c\">if (payload) {\n\/\/\u8bb0\u5f55cgroup\u7684fd\u503c\uff0c\u540e\u9762\u4f1a\u7528\u5230\u3002\n        h-&gt;cgfd_con = lxc_open_dirfd(path);\n        if (h-&gt;cgfd_con &lt; 0)\n            return log_error_errno(false, errno, &quot;Failed to open %s&quot;, path);\n        h-&gt;container_full_path = move_ptr(path);\n    } else {\n        h-&gt;cgfd_mon = lxc_open_dirfd(path);\n        if (h-&gt;cgfd_mon &lt; 0)\n            return log_error_errno(false, errno, &quot;Failed to open %s&quot;, path);\n        h-&gt;monitor_full_path = move_ptr(path);\n    }<\/code><\/pre>\n<p>2) monitor_enter<br \/>\n\u8fdb\u5165monitor cgroup\uff0c\u5c06\u5bb9\u5668\u8fdb\u7a0b\u7684pid\u5199\u5165monitor cgroup\u7684cgroup.procs\u6587\u4ef6\u91cc<br \/>\n3\uff09monitor_delegate_controllers<\/p>\n<h5><span class=\"ez-toc-section\" id=\"i-2\"><\/span><code>-------------------------------------------------------------------------------------------------<\/code><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\/\/TODO\uff0c\u672a\u5b8c\u5f85\u7eed<\/p>\n<h5><span class=\"ez-toc-section\" id=\"3-2-2%EF%BC%89%E5%AD%B5%E5%8C%96%E5%AE%B9%E5%99%A8%EF%BC%88%E4%B8%BBNAMESPACE%E9%80%BB%E8%BE%91%E5%A4%84%E7%90%86%EF%BC%89\"><\/span>3-2-2\uff09\u5b75\u5316\u5bb9\u5668\uff08\u4e3bNAMESPACE\u903b\u8f91\u5904\u7406\uff09<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u2192\u2192\u2192\u2192\u91cd\u8981\u65b9\u6cd52\uff1a<code>lxc_spawn\uff08\u5b75\u5316\u5bb9\u5668\uff0c\u518d\u6b21\u521b\u5efa\u5b50\u8fdb\u7a0bpayload\uff09<\/code><br \/>\n\u65b9\u6cd5\u8bf4\u660e\uff1a<\/p>\n<pre><code class=\"language-bash\">\/* lxc_spawn() performs crucial setup tasks and clone()s the new process which\n * exec()s the requested container binary.\n * Note that lxc_spawn() runs in the parent namespaces. Any operations performed\n * right here should be double checked if they&#039;d pose a security risk. (For\n * example, any {u}mount() operations performed here will be reflected on the\n * host!)\n *\/<\/code><\/pre>\n<pre><code class=\"language-c\">\/\/\u521b\u5efasocket\u5bf9\uff0c\u5b58\u4e8ehandler-&gt;sync_sock\u3002\uff08\u7528\u4e8emonitor\u4e0epayload\u8fdb\u7a0b\u540c\u6b65\uff09\nlxc_sync_init\n\n\/\/\u521b\u5efasocket\u5bf9\uff0c\u5b58\u4e8ehandler-&gt;data_sock<\/code><\/pre>\n<p>\/\/<strong>\u89e3\u6790\u547d\u4ee4\u7a7a\u95f4\u514b\u9686\u6807\u8bb0<\/strong><\/p>\n<pre><code class=\"language-c\">resolve_clone_flags\n\u4e3b\u8981\u6709\nCloned CLONE_NEWNS\nCloned CLONE_NEWPID\nCloned CLONE_NEWUTS\nCloned CLONE_NEWIPC\nCloned CLONE_NEWNET\n\nint resolve_clone_flags(struct lxc_handler *handler)\n{\n    int i;\n    struct lxc_conf *conf = handler-&gt;conf;\n    for (i = 0; i &lt; LXC_NS_MAX; i++) {\n            if (i == LXC_NS_USER &amp;&amp; lxc_list_empty(&amp;handler-&gt;conf-&gt;id_map))\n                continue;\n            \/\/\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e\u4e86\u7f51\u7edc\u624d\u4f1a\u514b\u9686\u7f51\u7edc\u547d\u540d\u7a7a\u95f4\n            if (i == LXC_NS_NET &amp;&amp; lxc_requests_empty_network(handler))\n                continue;\n\n            \/\/`\/proc\/self\/ns\/cgroup`\u6587\u4ef6\u5b58\u5728\u624d\u652f\u6301\u514b\u9686CGROUP\u547d\u540d\u7a7a\u95f4\n            if (i == LXC_NS_CGROUP &amp;&amp; !cgns_supported())\n                continue;\n\n            handler-&gt;ns_clone_flags |= ns_info[i].clone_flag;\n        }\n}<\/code><\/pre>\n<pre><code class=\"language-c\">\/\/\u521b\u5efapayload cgroup\npayload_create\n\n\/\/share_ns\u4e3afalse\n\/\/\u8c03\u7528\u5185\u8054\u6c47\u7f16\u8fdb\u884c\u8fdb\u7a0b\u7684\u514b\u9686\uff08lxc-start 2\u6b21fork\u51fa\u6765\u7684\u5b50\u8fdb\u7a0b\u518dclone\u4e2a\u65b0\u8fdb\u7a0b\uff09\n\/\/\u6ce8\u610f\uff1aclone\u7684\u5b50\u8fdb\u7a0b\u4f1a\u6709\u8bf8\u591a\u7684\u547d\u540d\u7a7a\u95f4\uff0c\u6240\u4ee5\u548c\u7236\u8fdb\u7a0b\u4e4b\u95f4\u5229\u7528socket\u8de8\u547d\u540d\u7a7a\u95f4\u901a\u8baf\u3002\nhandler-&gt;pid = lxc_raw_clone_cb(do_start, handler,\n                        CLONE_PIDFD | handler-&gt;ns_on_clone_flags,\n                        &amp;handler-&gt;pidfd);<\/code><\/pre>\n<p><strong>##<\/strong> \u5230\u6b64\u4e3a\u6b62\uff0clxc-start\u547d\u4ee4\u521b\u5efa\u7684\u8fdb\u7a0b\u592a\u591a\u4e86\uff0c\u4e3a\u4e86\u4fbf\u4e8e\u533a\u5206\uff0c\u540e\u9762\u7edf\u4e00\u89c4\u5b9a\uff1a\u5b88\u62a4\u8fdb\u7a0b\u53eb\u505a<strong>monitor\u8fdb\u7a0b<\/strong>\uff0c\u7531monitor\u8fdb\u7a0bclone\u51fa\u6765\u7684\u8fd9\u4e2a\u8fdb\u7a0b\u53eb\u505a<strong>payload\u8fdb\u7a0b<\/strong>\u3002 <strong>##<\/strong><\/p>\n<p><strong>lxc_raw_clone_cb<\/strong>\u51fd\u6570\uff1a<br \/>\n<code>-------------------------------------------------------------------------------------------------<\/code><\/p>\n<pre><code class=\"language-c\">pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args, unsigned long flags,\n               int *pidfd)\n{\n    pid_t pid;\n\n    pid = lxc_raw_clone(flags, pidfd);\n    if (pid &lt; 0)\n        return -1;\n\n    \/*lxc_raw_clone\n     * exit() is not thread-safe and might mess with the parent&#039;s signal\n     * handlers and other stuff when exec() fails.\n     *\/\n    if (pid == 0)\n        _exit(fn(args));\n\n    return pid;\n}<\/code><\/pre>\n<p>\u90a3\u4e48\u5b50\u8fdb\u7a0bpayload\u8fdb\u7a0b\u5c06\u6267\u884cdo_start(void *data)\u65b9\u6cd5<\/p>\n<p><code>-------------------------------------------------------------------------------------------------<\/code><\/p>\n<h6><span class=\"ez-toc-section\" id=\"3-2-2-1%EF%BC%89monitor%E8%BF%9B%E7%A8%8B%E7%BB%A7%E7%BB%AD%E6%89%A7%E8%A1%8C\"><\/span>3-2-2-1\uff09monitor\u8fdb\u7a0b\u7ee7\u7eed\u6267\u884c<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<pre><code class=\"language-c\">\u540e\u9762\u6267\u884c\u7684\u90fd\u662fmonitor\u8fdb\u7a0b\uff01\uff01\n\n\/\/\u8bb0\u5f55clone\u51fa\u6765\u7684\u8fdb\u7a0bid\u5230\u73af\u5883\u53d8\u91cf\nret = setenv(&quot;LXC_PID&quot;, pidstr, 1);\n\n\/* lxc_try_preserve_namespaces: open \/proc\/@pid\/ns\/@ns for each namespace\n * specified in ns_clone_flags.\n * Return true on success, false on failure.\n *\/\n\/\/\u4e0b\u9762\u65b9\u6cd5\u4f1a\u5c06\u5b50\u8fdb\u7a0b\/proc\/payload_pid\/ns\u4e0b\u7684\u547d\u540d\u7a7a\u95f4\u6587\u4ef6\u6253\u5f00\uff0c\u5e76\u4e14fd\u5b58\u50a8\u4e8ehandler-&gt;nsfd\u6570\u7ec4\u4e2d\uff0c\u540e\u9762\u4f1a\u7528\u5230\u3002\nlxc_try_preserve_namespaces\n\n\/\/\u5173\u95ed\u7236\u8fdb\u7a0b\u7684sync_sock[0]\nlxc_sync_fini_child\n\n\/\/send status file descriptor to child process\n\/\/\u89e3\u9664\u5b50\u8fdb\u7a0b\u7684socket\u963b\u585e\u70b9\nlxc_abstract_unix_send_fds(handler-&gt;data_sock[0], &amp;handler-&gt;monitor_status_fd, 1, NULL, 0)\n\n\/\/\u89e3\u9664\u5b50\u8fdb\u7a0b\u7684socket\u963b\u585e\u70b9\u3002\uff08\u539f\u7406\uff1apayload\u8fdb\u7a0b\u5229\u7528socket recv\u963b\u585e\uff0c\u8fd9\u91cc\u53d1\u4e2a\u6d88\u606f\u89e3\u9664\u963b\u585e\u3002\uff09\nret = lxc_sync_wake_child(handler, LXC_SYNC_STARTUP);\n\n\/\/\u7236\u8fdb\u7a0b\u963b\u585e\uff0c\u7b49\u5f85\u88ab\u5b50\u8fdb\u7a0b\u5524\u9192\uff0c\u6b64\u65f6\u6700\u597d\u770b\u770b\u5b50\u8fdb\u7a0b\u5524\u9192\u7236\u8fdb\u7a0b\u4e4b\u524d\u5e72\u4e86\u4e9b\u5565\u3002\nret = lxc_sync_wait_child(handler, LXC_SYNC_CONFIGURE);\n\n\/\/\u4e0b\u9762\u5c31\u662f\u5bf9cgroup\u7684\u4e00\u4e9b\u64cd\u4f5c\n\/\/\u7ba1\u7406payload\u8fdb\u7a0b\uff0c\u5c06\u5176\u8fdb\u7a0bid\u5199\u5165lxc.payload.android1\u7684cgroup.procs\u6587\u4ef6\u4e2d\u3002\ncgroup_ops-&gt;payload_enter(cgroup_ops, handler)\n...<\/code><\/pre>\n<p>\/\/\u521b\u5efa\u7f51\u7edc\u5e76\u901a\u77e5\u5b50\u8fdb\u7a0b<\/p>\n<pre><code class=\"language-c\">\/\/\u8bbe\u7f6e\u5bb9\u5668\u7f51\u7edc\u547d\u540d\u7a7a\u95f4\u7684\u7f51\u7edcID\nret = lxc_netns_set_nsid(handler-&gt;nsfd[LXC_NS_NET]);\n\n\/\/1.\u521b\u5efa\u7f51\u7edc\n\u2192ret = lxc_create_network(handler);\n\/\/\u8c03\u7528netlink\u63a5\u53e3\u8fdb\u884c\u7f51\u7edc\u7684\u914d\u7f6e\n\u2192\u2192lxc_create_network_priv(handler);\n\/\/\u5c06\u521b\u5efa\u7684\u7f51\u7edc\u8bbe\u5907\u79fb\u81f3payload\u8fdb\u7a0b\u7684\u7684\u7f51\u7edc\u547d\u540d\u7a7a\u95f4\n\u2192\u2192lxc_network_move_created_netdev_priv(handler);\n\n\/\/2.\u5c06\u7f51\u7edc\u4fe1\u606f\u53d1\u9001\u7ed9\u5b50\u8fdb\u7a0b\uff0c\u4e3a\u4ec0\u4e48\u8981\u53d1\uff1f      \n\u2192ret = lxc_network_send_to_child(handler);<\/code><\/pre>\n<pre><code class=\"language-c\">\/\/\u8bbe\u7f6e\/proc\u6587\u4ef6\u7cfb\u7edf\uff08\u53ef\u9009\uff09\nsetup_proc_filesystem\n\n\/\/\nsetup_resource_limits\n\n\/* Tell the child to continue its initialization. We&#039;ll get\n* LXC_SYNC_CGROUP when it is ready for us to setup cgroups.\n*\/\nret = lxc_sync_barrier_child(handler, LXC_SYNC_POST_CONFIGURE);\n\n\/\/\nsetup_resource_limits\n\n\/\/\u963b\u585e\u7b49\u5f85\u5b50\u8fdb\u7a0b\u901a\u77e5\u8bbe\u7f6eCGROUP\nret = lxc_sync_barrier_child(handler, LXC_SYNC_CGROUP_UNSHARE);\n\n...\n\n\/\/\u6253\u5370init\u7a0b\u5e8f\u5df2\u7ecf\u542f\u52a8\u7684\u65e5\u5fd7\nret = handler-&gt;ops-&gt;post_start(handler, handler-&gt;data);\n\n\/\/\u8bbe\u7f6e\u5bb9\u5668\u72b6\u6001\u4e3aRUNNING\nret = lxc_set_state(name, handler, RUNNING);\n\n\/\/\u5173\u95edsync_sock\u5bf9\uff0c\u81f3\u6b64\uff0c\u7236\u5b50\u8fdb\u7a0b\u4ea4\u4e92\u5b8c\u6bd5\u3002\nlxc_sync_fini<\/code><\/pre>\n<h6><span class=\"ez-toc-section\" id=\"3-2-2-2%EF%BC%89payload%E8%BF%9B%E7%A8%8B%E5%B9%B2%E4%BA%86%E4%BA%9B%E5%95%A5\"><\/span>3-2-2-2\uff09payload\u8fdb\u7a0b\u5e72\u4e86\u4e9b\u5565<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<p>\u6ce8\u610fclone\u4e4b\u540e\u7684\u5b50\u8fdb\u7a0b\u83b7\u53d6pid\u4e0d\u80fd\u76f4\u63a5\u8c03\u7528\u7cfb\u7edf\u7684getpid\u65b9\u6cd5\uff0c\u8981\u8c03\u7528lxc_raw_getpid\u65b9\u6cd5\uff01<\/p>\n<pre><code class=\"language-c\">\/\/\u5173\u95edsync_sock[1]\nlxc_sync_fini_parent(handler);\n\n\/\/\u963b\u585e\u8fdb\u7a0b\uff0c\u7b49\u5f85\u7236\u8fdb\u7a0b\u901a\u8fc7socket\u5524\u9192\u3002\nlxc_abstract_unix_recv_fds\n\n\/\/\u9632\u6b62\u8fdb\u7a0b\u53d8\u6210\u50f5\u5c38\u8fdb\u7a0b\uff0c\u5982\u679c\u7236\u8fdb\u7a0b\u88abkill\u6389\uff0c\u5f53\u524d\u8fdb\u7a0b\u4e5f\u4f1a\u88abkill.\nlxc_set_death_signal\n\n\/\/\u8bbe\u7f6e\u7ebf\u7a0b\u63a9\u7801\npthread_sigmask\n\n\/\/\u5173\u95edpinfd\u6587\u4ef6\nclose_prot_errno_disarm(handler-&gt;pinfd)\n\n\/\/\u963b\u585e\u8fdb\u7a0b\uff0c\u7b49\u5f85\u7236\u8fdb\u7a0b\u901a\u8fc7socket\u5524\u9192\u3002\nret = lxc_sync_wait_parent(handler, LXC_SYNC_STARTUP);\n\n\/* Tell the parent task it can begin to configure the container and wait\n* for it to finish.\n*\/\nret = lxc_sync_barrier_parent(handler, LXC_SYNC_CONFIGURE);\n\n\/\/\u63a5\u6536\u7236\u8fdb\u7a0b\u53d1\u9001\u7684\u7f51\u7edc\u8bbe\u5907\u540d\u79f0\nlxc_network_recv_from_parent\n\n\/* Ask father to setup cgroups and wait for him to finish. *\/\nret = lxc_sync_barrier_parent(handler, LXC_SYNC_CGROUP);\n\n\/\/\u5c06\u5b50\u8fdb\u7a0b\u52a0\u5165\u65b0\u5efaCGROUP\u547d\u540d\u7a7a\u95f4\n\/\/\u5b50\u8fdb\u7a0bclone\u65f6\u5df2\u7ecf\u5e26\u4e86CLONE_NEWCGROUP\u7684flag\uff0c\u600e\u4e48\u8fd9\u91cc\u8fd8\u8981\u518d\u6b21unshare?\u6e90\u7801\u4f5c\u4e86\u8be6\u5c3d\u7684\u8bf4\u660e\nret = unshare(CLONE_NEWCGROUP);\n<\/code><\/pre>\n<p>\u6ce8\u610f\u7236\u5b50\u8fdb\u7a0b\u6709\u591a\u5904socket\u963b\u585e\u5f02\u6b65\u901a\u4fe1\u7684\u5730\u65b9\uff1a<br \/>\n1\uff09(\u5b50\u963b\u585e\u7b49\u5f85)lxc_abstract_unix_recv_fds <code>--<\/code> (\u7236\u89e3\u963b\u585e\u5524\u9192)lxc_abstract_unix_send_fds<br \/>\n2\uff09(\u5b50\u963b\u585e\u7b49\u5f85)lxc_sync_wait_parent LXC_SYNC_STARTUP <code>--<\/code> (\u7236\u89e3\u963b\u585e\u5524\u9192)lxc_sync_wake_child LXC_SYNC_STARTUP<br \/>\n3\uff09(\u7236\u963b\u585e\u7b49\u5f85)lxc_sync_wait_child LXC_SYNC_CONFIGURE <code>--<\/code> (\u5b50\u89e3\u963b\u585e\u5524\u9192\u5e76\u7b49\u5f85)lxc_sync_barrier_parent LXC_SYNC_CONFIGURE<br \/>\n(\u7236\u89e3\u963b\u585e\u5524\u9192)lxc_sync_barrier_child LXC_SYNC_POST_CONFIGURE <code>--<\/code> \u89e3\u9664\u4e0a\u9762\u5b50\u8fdb\u7a0b\u7684LXC_SYNC_CONFIGURE\u7684\u7b49\u5f85\u3002<br \/>\n...<\/p>\n<pre><code class=\"language-c\">enum {\n    LXC_SYNC_STARTUP,\n    LXC_SYNC_CONFIGURE,\n    LXC_SYNC_POST_CONFIGURE,\n    LXC_SYNC_CGROUP,\n    LXC_SYNC_CGROUP_UNSHARE,\n    LXC_SYNC_CGROUP_LIMITS,\n    LXC_SYNC_READY_START,\n    LXC_SYNC_RESTART,\n    LXC_SYNC_POST_RESTART,\n    LXC_SYNC_ERROR = -1 \/* Used to report errors from another process *\/\n};\n\n\/\/\u6b64\u65b9\u6cd5\u901a\u8fc7LXC_SYNC_XX\u679a\u4e3e\u5b9e\u73b0\u7cbe\u5bc6\u7684\u6d41\u7a0b\u4ea4\u4e92\u4e0e\u63a8\u8fdb\n\/\/\u4ee3\u7801\u8ffd\u8e2a\u65f6\u901a\u8fc7\u8fd9\u4e9b\u679a\u4e3e\u5b9a\u4f4d\u4f1a\u66f4\u5feb\nstatic int __sync_barrier(int fd, int sequence)\n{\n    if (__sync_wake(fd, sequence))\n        return -1;\n    return __sync_wait(fd, sequence+1);\n}\n<\/code><\/pre>\n<p>\u5373\u4f7f\u7236\u8fdb\u7a0b\u62a2\u5148\u8fd0\u884c\uff0c\u5148\u53d1\u9001\u963b\u585e\u5524\u9192\uff0c\u5b50\u8fdb\u7a0b\u8d77\u6765\u4e4b\u540e\u963b\u585e\u7b49\u5f85\u4f9d\u7136\u4f1a\u6536\u5230\u6570\u636e\u89e3\u9664\u963b\u585e\uff01<\/p>\n<p><strong>1.lxc_setup(\u5b50\u8fdb\u7a0b\u8bbe\u7f6e\uff0c\u975e\u5e38\u91cd\u8981)<\/strong><code>--------------------------------<\/code><br \/>\n\/<em> Setup the container, ip, names, utsname, ... <\/em>\/<\/p>\n<p><strong>\u21921.lxc_setup_rootfs_prepare_root<\/strong><br \/>\n\u2192\u2192remount_all_slave<br \/>\n\u5c06\u672c\u8fdb\u7a0b\u7684\/proc\/self\/mountinfo\u4e0b\u7684\u6302\u8f7d\u70b9\u91cd\u65b0\u4ee5MS_SLAVE\u7684\u4f20\u64ad\u7c7b\u578b\u6302\u8f7d\uff0c\u5229\u7528sendfile\u6280\u672f\u62f7\u8d1d\u8bfb\u53d6\/proc\/self\/mountinfo\u6587\u4ef6\u91cc\u7684\u6302\u8f7d\u4fe1\u606f\u3002<\/p>\n<p>\u2192\u2192 ret = run_lxc_hooks(name, &quot;pre-mount&quot;, conf, NULL);<br \/>\n\u5e95\u5c42\u8c03\u7528exec\u6267\u884c\u547d\u4ee4<\/p>\n<p>\u2192\u2192 ret = lxc_mount_rootfs(conf);<br \/>\n\/\/\u521d\u59cb\u5316lxc_storage\u7ed3\u6784\u4f53\uff0c\u5b58\u50a8\u6839\u6587\u4ef6\u7cfb\u7edf\u76f8\u5173\u4fe1\u606f\u3002<br \/>\n\u2192\u2192\u2192 1\uff09bdev = storage_init(conf);<\/p>\n<pre><code class=\"language-c\">\/* When lxc is mounting a rootfs, then src will be the &quot;lxc.rootfs.path&quot; value,\n * dest will be the mount dir (i.e. &quot;&lt;libdir&gt;\/lxc&quot;)  When clone or create is\n * doing so, then dest will be &quot;&lt;lxcpath&gt;\/&lt;lxcname&gt;\/rootfs&quot;, since we may need\n * to rsync from one to the other.\n *\/\nstruct lxc_storage {\n    \/\/\n    const struct lxc_storage_ops *ops;\n    const char *type;\n    char *src;\n    char *dest;\n    char *mntopts;\n    \/* Turn the following into a union if need be. *\/\n    \/* lofd is the open fd for the mounted loopback file. *\/\n    int lofd;\n    \/* index for the connected nbd device. *\/\n    int nbd_idx;\n    int flags;\n};\n\nstatic const struct lxc_storage_type bdevs[] = {\n    { .name = &quot;dir&quot;,       .ops = &amp;dir_ops,   },\n    { .name = &quot;zfs&quot;,       .ops = &amp;zfs_ops,   },\n    { .name = &quot;lvm&quot;,       .ops = &amp;lvm_ops,   },\n    { .name = &quot;rbd&quot;,       .ops = &amp;rbd_ops,   },\n    { .name = &quot;btrfs&quot;,     .ops = &amp;btrfs_ops, },\n    { .name = &quot;overlay&quot;,   .ops = &amp;ovl_ops,   },\n    { .name = &quot;overlayfs&quot;, .ops = &amp;ovl_ops,   },\n    { .name = &quot;loop&quot;,      .ops = &amp;loop_ops,  },\n    { .name = &quot;nbd&quot;,       .ops = &amp;nbd_ops,   },\n};\n<\/code><\/pre>\n<p>\u2192\u2192\u2192\u2192q = storage_query(conf);<br \/>\n\u6700\u7ec8q\u4e3abdevs[0]\u4e5f\u5c31\u662fdir\u7c7b\u578blxc_storage_type\u7ed3\u6784\u4f53<\/p>\n<p>\u2192\u2192\u2192\u2192\u52a8\u6001\u5185\u5b58\u521b\u5efalxc_storage\uff0c\u4f1a\u590d\u5236q\u7684\u6570\u636e\u3002<\/p>\n<p>\u2192\u2192\u2192 2\uff09ret = bdev-&gt;ops-&gt;mount(bdev);<br \/>\n\u8c03\u7528dir_mount\u65b9\u6cd5\uff0c\u5229\u7528bind\u6302\u8f7d\u6280\u672f\u6302\u8f7d\u6839\u6587\u4ef6\u7cfb\u7edf(\u5b9e\u9645\u662f\u4e2a\u76ee\u5f55)<br \/>\n\u6700\u7ec8\u6302\u8f7d\u6210\u529f\u63d0\u793a\uff1a<code> Mounted &quot;\/data\/media\/build_lxc\/containers\/android1\/rootfs&quot; on &quot;\/data\/media\/build_lxc\/lib\/lxc\/rootfs&quot;<\/code><\/p>\n<p>\u4f46\u662f\u67e5\u770b\/data\/media\/build_lxc\/lib\/lxc\/rootfs\u4e0b\u4e3a\u7a7a\uff0c\u56e0\u4e3a\u73b0\u5728\u5904\u4e8e\u7236\u8fdb\u7a0b\u547d\u540d\u7a7a\u95f4\uff0c\u8981\u901a\u8fc7<code>nsenter -t pid -m sh<\/code>\u624d\u80fd\u770b\u5230\u6302\u8f7d\u89c6\u56fe\u3002<\/p>\n<p>\u2192\u2192\u2192 3\uff09storage_put(bdev);<br \/>\n\u91ca\u653e\u5185\u5b58<\/p>\n<p><strong>\u21922.setup_utsname<\/strong><br \/>\nlxc_conf-&gt;utsname\u4e3aNULL\uff0c\u6240\u4ee5\u5b9e\u9645\u6ca1\u6709\u8bbe\u7f6e\u3002<\/p>\n<p><strong>\u21923.lxc_setup_keyring<\/strong><br \/>\n\u5bc6\u94a5\u4fdd\u7559\u670d\u52a1<br \/>\n\/* Try to allocate a new session keyring for the container to prevent<\/p>\n<ul>\n<li>information leaks.<br \/>\n*\/<br \/>\nkeyctl(KEYCTL_JOIN_SESSION_KEYRING\uff09<\/li>\n<\/ul>\n<p>\/\/\u5b50\u8fdb\u7a0b\u7f51\u5361\u8bbe\u7f6e<br \/>\n<strong>\u21924.lxc_setup_network_in_child_namespaces<\/strong><\/p>\n<p>\/\/\u8bbe\u7f6emac\u5730\u5740,ip\u5730\u5740\u7b49\u4fe1\u606f\u3002<br \/>\n\u2192\u2192lxc_network_setup_in_child_namespaces_common<\/p>\n<p><strong>\u21925.mount_autodev<\/strong><br \/>\n\u5728\u5bb9\u5668\u8fdb\u7a0b\u6302\u8f7d\u597d\u7684rootfs\u4e0b\u521b\u5efa\u4e00\u4e2adev\u76ee\u5f55\uff0c\u7136\u540e\u6302\u8f7d\u4e00\u4e2atmpfs\u5185\u5b58\u6587\u4ef6\u7cfb\u7edf\uff0c\u7528\u4e8e\u4fdd\u5b58\u65e5\u5fd7\u3002<br \/>\n\u6302\u8f7d\u597d\/dev\u4e4b\u540e\uff0c\u53c8\u5728\u5176\u4e0b\u521b\u5efa\u4e86\u4e00\u4e2apts\u76ee\u5f55\u3002<\/p>\n<p><strong>\u21926.lxc_mount_auto_mounts<\/strong><br \/>\n\u5bf9\u5e94\u914d\u7f6e\u6587\u4ef6\u91cc\u7684<code>lxc.mount.auto<\/code><br \/>\n\/* Do automatic mounts (mainly \/proc and \/sys), but exclude those that<\/p>\n<ul>\n<li>need to wait until other stuff has finished.<br \/>\n*\/<br \/>\n\u4e3b\u8981\u7528\u4e8e\u6302\u8f7d\/proc \u548c \/sys\uff0c\u4f46\u662f\u5b9e\u9645debug\u6ca1\u6709\u6302\u8f7d\u5565\uff1f<br \/>\n<a href=\"https:\/\/zhuanlan.zhihu.com\/p\/633338117\">https:\/\/zhuanlan.zhihu.com\/p\/633338117<\/a><\/li>\n<\/ul>\n<p><strong>\u21927.setup_mount<\/strong><br \/>\nlxc_conf-&gt;rootfs\u4e3aNULL\uff0c\u5b9e\u9645\u4ec0\u4e48\u4e5f\u6ca1\u505a\u3002<\/p>\n<p><strong>\u21928.setup_mount_entries<\/strong><br \/>\n\u5bf9\u5e94\u914d\u7f6e\u6587\u4ef6\u91cc\u7684<code>lxc.mount.entry<\/code>\uff0c\u4e3b\u8981\u662f\u628a\u5bbf\u4e3b\u673a\u91cc\u7684\u4e00\u4e9b\u76ee\u5f55\u6620\u5c04\u6302\u8f7d\u5230\u5bb9\u5668\u8fdb\u7a0bmnt\u547d\u540d\u7a7a\u95f4\u91cc\u3002\uff08\u540e\u9762\u7edf\u4e00\u7b80\u79f0\u6302\u8f7d\u5230\u5bb9\u5668\u6839\u6587\u4ef6\u7cfb\u7edf\uff09<\/p>\n<p>\u2192\u2192make_anonymous_mount_file<br \/>\n\u521b\u5efa\u5185\u5b58\u6587\u4ef6\uff0c\u5e76\u5c06<code>lxc.mount.entry<\/code>\u7684\u6302\u8f7d\u4fe1\u606f\u5199\u5165\u6587\u4ef6\u3002<\/p>\n<p>\u2192\u2192mount_file_entries<br \/>\n\u6267\u884c\u4e0a\u9762\u7684\u6302\u8f7d\u6620\u5c04<\/p>\n<p><strong>\u21929.lxc_mount_auto_mounts<\/strong><br \/>\n\u7528\u4e8e\u6302\u8f7dcgroups<\/p>\n<p><strong>\u21929.lxc_fill_autodev<\/strong><br \/>\n\u5728\/dev\u4e0b\u521b\u5efa\u4e00\u4e9b\u8bbe\u5907\u6587\u4ef6\u8282\u70b9\uff0c\u5229\u7528mknod\u51fd\u6570\u3002<\/p>\n<pre><code class=\"language-c\">static const struct lxc_device_node lxc_devices[] = {\n    { &quot;full&quot;,    S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 7 },\n    { &quot;null&quot;,    S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 3 },\n    { &quot;random&quot;,  S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 8 },\n    { &quot;tty&quot;,     S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 5, 0 },\n    { &quot;urandom&quot;, S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 9 },\n    { &quot;zero&quot;,    S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 5 },\n};\n<\/code><\/pre>\n<p><strong>\u219210.lxc_setup_console<\/strong><br \/>\nttydir\u5373\u5bf9\u5e94\u914d\u7f6e\u6587\u4ef6<code>lxc.tty.dir<\/code>\uff0c\u7528\u4e8e\u540e\u7eed\u5728\/dev\/ttydir\u76ee\u5f55\u4e0b\u521b\u5efatty\u8bbe\u5907\u3002<\/p>\n<pre><code class=\"language-c\">static int lxc_setup_console(const struct lxc_rootfs *rootfs,\n                 const struct lxc_terminal *console, char *ttydir)\n{\n    if (!ttydir)\n        return lxc_setup_dev_console(rootfs, console);\n\n    return lxc_setup_ttydir_console(rootfs, console, ttydir);\n}<\/code><\/pre>\n<p>\u2192\u2192lxc_setup_ttydir_console<br \/>\n1\uff09\u521b\u5efattydir\u76ee\u5f55<br \/>\n2\uff09ttydir\u76ee\u5f55\u4e0b\u521b\u5efaconsole\u8bbe\u5907<\/p>\n<pre><code class=\"language-c\">ret = snprintf(lxcpath, sizeof(lxcpath), &quot;%s\/dev\/%s\/console&quot;, rootfs_path, ttydir);\nret = mknod(lxcpath, S_IFREG | 0000, 0);<\/code><\/pre>\n<p>3\uff09\u5982\u679crootfs\/dev\/console\u8bbe\u5907\u8282\u70b9\u5b58\u5728\uff0c\u6267\u884clazy\u5378\u8f7d\u3002<\/p>\n<pre><code class=\"language-c\">ret = snprintf(path, sizeof(path), &quot;%s\/dev\/console&quot;, rootfs_path);\n    if (ret &lt; 0 || (size_t)ret &gt;= sizeof(path))\n        return -1;\n\n    if (file_exists(path)) {\n        ret = lxc_unstack_mountpoint(path, false);\n    }<\/code><\/pre>\n<p>4\uff09\u521b\u5efarootfs\/dev\/console\u8bbe\u5907\u8282\u70b9<br \/>\n<code>ret = mknod(path, S_IFREG | 0000, 0);<\/code><\/p>\n<p>5\uff09\u5c06\u5bbf\u4e3b\u673a\u91ccconsole\u7ed1\u5b9a\u5230\u5bb9\u5668\u91cc\u7684console<br \/>\n<code>\/* bind mount console-&gt;name to &#039;rootfs\/dev\/&lt;ttydir&gt;\/console&#039; *\/<\/code><br \/>\n\u5982<code>Mounted &quot;\/dev\/pts\/1&quot; onto &quot;\/data\/media\/build_lxc\/lib\/lxc\/rootfs\/dev\/lxc\/console&quot;<\/code><\/p>\n<p>6) \u5c06\u5bb9\u5668\u91cc\u7684\/dev\/<ttydir>\/console\u6302\u8f7d\u5230\/dev\/console<br \/>\n<code>\/* bind mount &#039;\/dev\/&lt;ttydir&gt;\/console&#039;  to &#039;\/dev\/console&#039;  *\/<\/code><\/p>\n<p><strong>\u219211.lxc_setup_dev_symlinks<\/strong><br \/>\n\u5728\/dev\u4e0b\u521b\u5efa\u94fe\u63a5\u6587\u4ef6<\/p>\n<pre><code class=\"language-c\">\/dev\/fd -&gt; \/proc\/self\/fd\n\/dev\/stderr -&gt; \/proc\/self\/fd\/2\n\/dev\/stdin -&gt; \/proc\/self\/fd\/0\n\/dev\/stdout -&gt; \/proc\/self\/fd\/1<\/code><\/pre>\n<p><strong>\u219212.lxc_create_tmp_proc_mount<\/strong><br \/>\n\u5c06\u5bbf\u4e3b\u673a\u91cc\u7684\/proc\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\/proc\u4e0b<\/p>\n<p><strong>\u219213.lxc_setup_rootfs_switch_root<\/strong><\/p>\n<pre><code class=\"language-c\">    \/\/\u5982\u679crootfs\u662f\u57fa\u4e8eramfs\u7684\uff08\u4e0d\u652f\u6301pivot_root\uff09\n    if (detect_ramfs_rootfs())\n        return lxc_chroot(rootfs);\n    \/\/\u4f1a\u8d70\u8fd9\u91cc\n    return lxc_pivot_root(rootfs-&gt;mount);<\/code><\/pre>\n<p>\u2192\u2192lxc_pivot_root<\/p>\n<p>\u6267\u884c\u6210\u529f\u4e4b\u540e\uff0c\u901a\u8fc7nsenter \u6307\u5b9a-m\u53c2\u6570\u62a5\u9519\uff1a<code>nsenter: exec sh: Too many symbolic links encountered<\/code>\uff0cwhy?<br \/>\n<code>-----------------------------------------------------------------<\/code><br \/>\n<strong>\u219214.lxc_setup_boot_id<\/strong><\/p>\n<p><strong>\u219215.lxc_setup_devpts<\/strong><\/p>\n<pre><code class=\"language-c\">\/\/\u5378\u8f7d\u539f\u6709\/dev\/pts\u6302\u8f7d\u70b9\n(void)umount2(&quot;\/dev\/pts&quot;, MNT_DETACH);\n\n\/\/\u6302\u8f7d\u65b0devpts\u5b9e\u4f8b\n    for (ret = -1, opts = mntopt_sets; opts &amp;&amp; *opts; opts++) {\n        \/* mount new devpts instance *\/\n        ret = mount(&quot;devpts&quot;, &quot;\/dev\/pts&quot;, &quot;devpts&quot;, MS_NOSUID | MS_NOEXEC, *opts);\n        if (ret == 0)\n            break;\n    }\n\n\/* Remove any pre-existing \/dev\/ptmx file. *\/\n    ret = remove(&quot;\/dev\/ptmx&quot;);\n\n\/* Create dummy \/dev\/ptmx file as bind mountpoint for \/dev\/pts\/ptmx. *\/\n    ret = mknod(&quot;\/dev\/ptmx&quot;, S_IFREG | 0000, 0);\n\n\/* Fallback option: create symlink \/dev\/ptmx -&gt; \/dev\/pts\/ptmx  *\/\n    ret = mount(&quot;\/dev\/pts\/ptmx&quot;, &quot;\/dev\/ptmx&quot;, NULL, MS_BIND, NULL);\n Failed to bind mount \\&quot;\/dev\/pts\/ptmx\\&quot; to \\&quot;\/dev\/ptmx\\&quot;&quot;);\n\n\/* Remove the dummy \/dev\/ptmx file we created above. *\/\n    ret = remove(&quot;\/dev\/ptmx&quot;);\n\n\/* Fallback option: Create symlink \/dev\/ptmx -&gt; \/dev\/pts\/ptmx. *\/\n    ret = symlink(&quot;\/dev\/pts\/ptmx&quot;, &quot;\/dev\/ptmx&quot;);<\/code><\/pre>\n<p><strong>\u219216.lxc_create_ttys<\/strong><br \/>\n\u2192\u2192ret = lxc_allocate_ttys(conf);<br \/>\n\u6839\u636e\u914d\u7f6e\u6587\u4ef6lxc.tty.max\u521b\u5efa\u82e5\u5e72\u4e2atty\u5bf9,\u5982\/dev\/pts\/0<\/p>\n<p>\u2192\u2192ret = lxc_send_ttys_to_parent(handler);<br \/>\n\u5c06\u521b\u5efatty\u8bbe\u5907\u4fe1\u606f\u53d1\u9001\u7ed9\u7236\u8fdb\u7a0b<\/p>\n<p>\u2192\u2192lxc_setup_ttys<br \/>\nBind mounted &quot;\/dev\/pts\/0&quot; onto &quot;\/dev\/lxc\/tty1&quot;<\/p>\n<p><strong>2.\u4e00\u4e9b\u5176\u5b83\u6267\u884c<\/strong><code>--------------------------------<\/code><\/p>\n<pre><code class=\"language-c\">ret = set_stdfds(handler-&gt;conf-&gt;console.slave);\n\n\/* If we mounted a temporary proc, then unmount it now. *\/\ntmp_proc_unmount(handler-&gt;conf);\n\n\/\/\u5b50\u8fdb\u7a0bpayload\u53d8\u6210\u5b88\u62a4\u8fdb\u7a0b\nsetsid();\n\nret = lxc_sync_barrier_parent(handler, LXC_SYNC_CGROUP_LIMITS);\n\nret = clearenv();\n\n\u9ed8\u8ba4\u662f\u6ca1\u6709\u81ea\u5b9a\u4e49new_uid\u4e0enew_gid\uff0c\u4f1a\u8d4b\u503c\nnew_uid = LXC_INVALID_UID;\nnew_gid = LXC_INVALID_GID;<\/code><\/pre>\n<p><strong>3.\u542f\u52a8init\u7a0b\u5e8f<\/strong><code>--------------------------------<\/code><br \/>\n\u6700\u7ec8\u8fdb\u7a0b\u8c03\u7528start\u65b9\u6cd5\uff0cstart\u8c03\u7528execvp\u65b9\u6cd5\u542f\u52a8init\u7a0b\u5e8f\u3002<\/p>\n<pre><code class=\"language-c\">handler-&gt;ops-&gt;start(handler, handler-&gt;data);\n\nstatic struct lxc_operations start_ops = {\n    .start = start,\n    .post_start = post_start\n};\n\nstatic int start(struct lxc_handler *handler, void* data)\n{\n    struct start_args *arg = data;\n\n    NOTICE(&quot;Exec&#039;ing \\&quot;%s\\&quot;&quot;, arg-&gt;argv[0]);\n\n    execvp(arg-&gt;argv[0], arg-&gt;argv);\n    SYSERROR(&quot;Failed to exec \\&quot;%s\\&quot;&quot;, arg-&gt;argv[0]);\n    return 0;\n}\n\nstatic int post_start(struct lxc_handler *handler, void* data)\n{\n    struct start_args *arg = data;\n\n    NOTICE(&quot;Started \\&quot;%s\\&quot; with pid \\&quot;%d\\&quot;&quot;, arg-&gt;argv[0], handler-&gt;pid);\n    return 0;\n}<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"3-2-3_%E5%AE%B9%E5%99%A8%E7%9B%91%E5%90%AC\"><\/span>3-2-3) \u5bb9\u5668\u76d1\u542c<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u2192\u2192\u2192\u2192\u91cd\u8981\u65b9\u6cd53\uff1a<code>lxc_poll\uff08\u5b75\u5316\u5bb9\u5668\uff09<\/code><br \/>\n\u5229\u7528epoll\u673a\u5236\u76d1\u542c\u5bb9\u5668\u7684\u4e8b\u4ef6\uff0c\u5982init\u5d29\u6e83\u4e8b\u4ef6\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E4%BA%8C%E3%80%81lxc-attach\"><\/span>\u4e8c\u3001lxc-attach<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u521b\u5efalxc_container\u5bf9\u8c61<br \/>\n<code>struct lxc_container *c = lxc_container_new(my_args.name, my_args.lxcpath[0]);<\/code><br \/>\n\u8c03\u7528lxc_container\u5bf9\u8c61\u7684attach\u65b9\u6cd5\uff0c\u4e5f\u5373\u662flxcapi_attach\u65b9\u6cd5<br \/>\n<code>ret = c-&gt;attach(c, lxc_attach_run_shell, NULL, &amp;attach_options, &amp;pid);<\/code><br \/>\nlxcapi_attach<br \/>\n\u2192lxc_attach<\/p>\n<pre><code class=\"language-cpp\">\/\/\u5224\u65ad\u662f\u5426\u652f\u6301namespace\u7279\u6027\nret = access(&quot;\/proc\/self\/ns&quot;, X_OK);\n\/\/\u83b7\u53d6\u5bb9\u5668\u7684\u521d\u59cb\u8fdb\u7a0b\u7684pid\uff08\u5e95\u5c42\u662f\u901a\u8fc7\u57dfsocket\u901a\u8baf\u5b9e\u73b0\uff09\ninit_pid = lxc_cmd_get_init_pid(name, lxcpath);<\/code><\/pre>\n<button class=\"simplefavorite-button\" data-postid=\"13200\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55 tool\u547d\u4ee4\u5404\u4e2a\u51fb\u7834\u96f6\u3001\u901a\u7528\u4ee3\u78011.\u547d\u4ee4\u884c\u89e3\u6790\u89e3\u6790\u65b9\u6cd5\u6570\u636e\u7ed3\u6784\u65e5\u5fd7\u4f4d\u7f6e\u53ca\u7b49\u7ea7\u8bbe\u5b9a\u81ea\u5b9a\u4e49lxc\u914d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1092],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/13200"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13200"}],"version-history":[{"count":194,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/13200\/revisions"}],"predecessor-version":[{"id":14283,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/13200\/revisions\/14283"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13200"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}