User Tools

Site Tools


user:rozlav

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
user:rozlav [2019-10-02 19:47] – Automatic creation by User Homepage plugin rozlavuser:rozlav [2023-03-14 16:35] (current) rozlav
Line 1: Line 1:
 ====== rozlav - Public Page ====== ====== rozlav - Public Page ======
-This public page ''//user:rozlav.txt//'', as stated by it's name **can be read by anyone but only you can edit it** (or a superuser)... +<markdown> 
-  * You can introduce yourself, add links to your contributions in this wiki, tell a story or present your other works +# Patcher du debian ! how to ? Avec des vrais morceaux de LXD dedans 
-  * Think about [[wp>http://en.wikipedia.org/wiki/Etiquette_in_technology|netiquette]] ;-+## 1Contexte : du LXD & du qemu-system 
-Limitations: + - pour une machine toute neuve debian sous Bookworm (testing à l'époque)qui nécessite de faire fonctionner des machines virtuelles (dites « vm/VM »grâce au logiciel de Canonical « LXD » (sorte de remplacant de lxc), il fallait patcher le paquet qemu-system. 
-  * You shouldn't create any other page in that namespace ''//user:rozlav//'' + - en passant du côté de `irc.libera.chat#qemu` et `irc.libera.chat#lxc` j'ai été redirigé []sur l'issue qui va bien](https://gitlab.com/qemu-project/qemu/-/issues/1486) mais vu que ça n'avançait pas : l'idée été de patcher w00t ! 
-  * Only superuser can add a picture+## 2. Reproduction du pépin (/¯◡ ‿ ◡)/¯ ~ ┻━┻ 
 +### 2.1 Install machine de base 
 +``` 
 +sudo apt update 
 +sudo apt install --no-install-recommends sudo vim etckeeper tig lnav screen htop borgbackup tcpstat nmap lsof iftop tcpdump tldr ncdu ripgrep unattended-upgrades gnupg debian-goodies apticron apt-listchanges ssmtp python3-pip 
 +sudo apt install lxd 
 +sudo apt install qemu-base qemu-utils qemu-system 
 +sudo apt upgrade 
 +```
  
-Feel free to remove this paragraph (beside the title)...\\ +### 2.2 Étapes avant le bug 
-Nowwrite something! :-D+ - lancement du bridge et création de la vm 
 +``` 
 +lxd --version 
 +5.0.2 
 +lxc network create UPLINK --type=physical parent=lxdbr0 
 ++-----------------+----------+---------+--------------+---------------------------+-------------+---------+---------+ 
 +|      NAME         TYPE   | MANAGED |     IPV4               IPV6            | DESCRIPTION | USED BY |  STATE  | 
 ++-----------------+----------+---------+--------------+---------------------------+-------------+---------+---------+ 
 +| lxdbr0          | bridge   | YES     | 10.98.2.1/24 | fd42:f0a7:adc5:f886::1/64 |             | 3       | CREATED | 
 +lxc launch images:debian/bullseye test0 --vm 
 +Error: Failed setting up device via monitor: Failed setting up device "eth0": Failed adding NIC netdev: Monitor is disconnected 
 +``` 
 + - erreur, liée à qemu-system https://gitlab.com/qemu-project/qemu/-/issues/1486 ) 
 +``` 
 +root@Selachimorpha:~# lxc info --show-log local:test0 
 +Name: test0 
 +Status: STOPPED 
 +Type: virtual-machine 
 +Architecture: x86_64 
 +Created: 2023/03/13 17:06 CET 
 +Log: 
 +warning: tap: open vhost char device failed: Permission denied 
 +warning: tap: open vhost char device failed: Permission denied 
 +qemu-system-x86_64: ../../net/net.c:1106: net_client_init1: Assertion `nc' failed
 +``` 
 +## 3. Tentative de résolution : patcher du paquet debian(○゜ε^○) 
 + - utilisation d'[]une ressource (maigre) de chez debian](https://wiki.debian.org/BuildingTutorial) 
 + - install des quelques paquets nécessaire à la (re)compilation 
 +``` 
 +sudo apt install build-essential fakeroot devscripts dpkg-dev gcc make automake pbuilder 
 +cd /home/roz/ && mkdir pkg-qemu-patching && cd pkg-qemu-patching/ 
 +sudo apt source qemu-system 
 +``` 
 + - création du patch[]téléchargé depuis la liste mail](https://www.mail-archive.com/qemu-devel@nongnu.org/msg924611.html) `vim debian/patches/0001-net-net.c-do-not-assert-nc-as-hotplug-vhost-net-may-.patch` : 
 +``` 
 +From b2bca483212f04b9b021753aec1fcaeaf41385d1 Mon Sep 17 00:00:00 2001 
 +From: Ming Yang <yangming73@huawei.com> 
 +Date: Fri, 25 Nov 2022 10:45:52 +0800 
 +Subject: [PATCH] net/net.c: Fix qemu crash when hot-pluging a vhost-net failed. 
  
 +Hot-pluging a vhost-net may cause virtual machine crash in following steps:
 +1. Starting a vm without net devices.
 +2. Hot-pluging 70 memory devices.
 +3. Hot-pluging a vhost-net device.
 +
 +The reason is : if hotplug a vhost-net failed, the nc cannot be found via function qemu_find_netdev, as
 +it has been cleaned up through function qemu_cleanup_net_client. Which leads to the result
 +that assert(nc) failed, then qemu crashed.
 +
 +While, the root reason is that, in commit 46d4d36d0bf2 if not both has_vhostforce and vhostforce flags
 +are true, the errp would not be set. Then net_init_tap would not return a negative value, fallowed by founding nc
 +and assert nc.
 +
 +In this patch, asserting nc is replaced with setting an error message.
 +
 +Fixes: 46d4d36d0bf2("tap: setting error appropriately when calling net_init_tap_one()")
 +Signed-off-by: Ming Yang <yangming73@huawei.com>
 +Signed-off-by: Liang Zhang <zhangliang5@huawei.com>
 +https://gitlab.com/qemu-project/qemu/-/issues/1486
 +---
 + net/net.c | 11 ++++++++++-
 + 1 file changed, 10 insertions(+), 1 deletion(-)
 +
 +diff --git a/net/net.c b/net/net.c
 +index 840ad9dca5..1d1d7e54c4 100644
 +--- a/net/net.c
 ++++ b/net/net.c
 +@@ -1103,7 +1103,16 @@ static int net_client_init1(const Netdev *netdev, bool is_netdev, Error **errp)
 + 
 +     if (is_netdev) {
 +         nc = qemu_find_netdev(netdev->id);
 +-        assert(nc);
 ++        /*
 ++         * If the tap of hotpluged net device do not has both has_vhostforce flag and vhostforce flags,
 ++         * when error occurs, the error messags will be report but not set to errp. Thus net_client_init_fun
 ++         * will not return a negatave value. Therefore the value of nc might be NULL. To make qemu robust,
 ++         * it is better to judge if nc is NULL.
 ++         */
 ++        if (!nc) {
 ++            error_setg(errp, "Device '%s' could not be initialized", netdev->id);
 ++            return -1;
 ++        }
 +         nc->is_netdev = true;
 +     }
 + 
 +-- 
 +2.33.0
 +```
 + - ajout du patch au fichier de conf' des trucs à compiler : `vim qemu-7.2+dfsg/debian/patches/series` :
 +```
 +# Assertion failed au moment du lxc-start/launch
 +0001-net-net.c-do-not-assert-nc-as-hotplug-vhost-net-may-.patch
 +```
 + - Compilation avec le patch, celui-ci devrait apparaître clairement via son nom (ici `0001-net-net.c-do-not-assert-nc-as-hotplug-vhost-net-may-.patch`) en début de compilation
 +```
 +cd /home/roz/pkg-qemu-patching/qemu-7.2+dfsg/
 +dpkg-buildpackage -us -uc
 +```
 + - Vérification :
 +```
 +root@Selachimorpha:/home/roz/pkg-qemu-patching# ls -la
 +total 864740
 +drwxr-xr-x  3 root root      4096 Mar 12 00:56 .
 +drwx------  4 roz  roz       4096 Mar 11 23:40 ..
 +drwxr-xr-x 60 root root      4096 Mar 12 00:56 qemu-7.2+dfsg
 +-rw-r--r--  1 root root  30315205 Mar 12 01:01 qemu_7.2+dfsg-4_amd64.build
 +-rw-r--r--  1 root root     32454 Mar 12 00:55 qemu_7.2+dfsg-4_amd64.buildinfo
 +-rw-r--r--  1 root root     12577 Mar 12 00:56 qemu_7.2+dfsg-4_amd64.changes
 +-rw-r--r--  1 root root    121624 Mar 11 23:51 qemu_7.2+dfsg-4.debian.tar.xz
 +-rw-r--r--  1 root root      5892 Mar 11 23:51 qemu_7.2+dfsg-4.dsc
 +-rw-r--r--  1 root root  23523172 Dec 15 15:32 qemu_7.2+dfsg.orig.tar.xz
 +-rw-r--r--  1 root root     86428 Mar 12 00:52 qemu-block-extra_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root    292220 Mar 12 00:52 qemu-block-extra-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root    324884 Mar 12 00:53 qemu-guest-agent_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root    949128 Mar 12 00:53 qemu-guest-agent-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root     31504 Mar 12 00:52 qemu-system_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   8981796 Mar 12 00:55 qemu-system-arm_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root  39860352 Mar 12 00:55 qemu-system-arm-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   2138480 Mar 12 00:53 qemu-system-common_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   7371508 Mar 12 00:53 qemu-system-common-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   1276368 Mar 12 00:52 qemu-system-data_7.2+dfsg-4_all.deb
 +-rw-r--r--  1 root root    297904 Mar 12 00:53 qemu-system-gui_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   1041592 Mar 12 00:53 qemu-system-gui-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root  13307612 Mar 12 00:53 qemu-system-mips_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root  55224640 Mar 12 00:54 qemu-system-mips-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root  46229776 Mar 12 00:54 qemu-system-misc_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root 193547560 Mar 12 00:55 qemu-system-misc-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   7538304 Mar 12 00:55 qemu-system-ppc_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root  31417836 Mar 12 00:55 qemu-system-ppc-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   5175268 Mar 12 00:53 qemu-system-sparc_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root  20431008 Mar 12 00:54 qemu-system-sparc-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   9255868 Mar 12 00:55 qemu-system-x86_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root  37281972 Mar 12 00:55 qemu-system-x86-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   2685276 Mar 12 00:53 qemu-system-xen_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root  10742216 Mar 12 00:53 qemu-system-xen-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root  12706240 Mar 12 00:54 qemu-user_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root      5344 Mar 12 00:55 qemu-user-binfmt_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root 135493288 Mar 12 00:55 qemu-user-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root  46142944 Mar 12 00:54 qemu-user-static_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root 132001404 Mar 12 00:55 qemu-user-static-dbgsym_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   1281392 Mar 12 00:55 qemu-utils_7.2+dfsg-4_amd64.deb
 +-rw-r--r--  1 root root   8260576 Mar 12 00:52 qemu-utils-dbgsym_7.2+dfsg-4_amd64.deb
 +```
 +## 4. Test !
 +```
 +cd /home/roz/pkg-qemu-patching
 +dpkg -i *.deb
 +```
 +</markdown>
user/rozlav.1570045635.txt.gz · Last modified: 2023-02-02 22:06 (external edit)