user:rozlav
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| user:rozlav [2023-02-02 22:06] – external edit 127.0.0.1 | user:rozlav [2023-03-14 16:35] (current) – rozlav | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== rozlav - Public Page ====== | ====== rozlav - Public Page ====== | ||
| - | This public page ''// | + | < |
| - | * 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/ | + | ## 1. Contexte : 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 |
| - | * You shouldn' | + | - en passant du côté de `irc.libera.chat#qemu` et `irc.libera.chat# |
| - | * Only a 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 | + | ### 2.2 Étapes avant le bug |
| - | Now, write something! | + | - lancement du bridge et création de la vm |
| + | ``` | ||
| + | lxd --version | ||
| + | 5.0.2 | ||
| + | lxc network create UPLINK --type=physical parent=lxdbr0 | ||
| + | +-----------------+----------+---------+--------------+---------------------------+-------------+---------+---------+ | ||
| + | | NAME | ||
| + | +-----------------+----------+---------+--------------+---------------------------+-------------+---------+---------+ | ||
| + | | lxdbr0 | ||
| + | lxc launch images: | ||
| + | Error: Failed setting up device via monitor: Failed setting up device " | ||
| + | ``` | ||
| + | - erreur, liée à qemu-system | ||
| + | ``` | ||
| + | root@Selachimorpha: | ||
| + | Name: test0 | ||
| + | Status: STOPPED | ||
| + | Type: virtual-machine | ||
| + | Architecture: | ||
| + | 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: | ||
| + | ``` | ||
| + | ## 3. Tentative de résolution : patcher du paquet debian(○゜ε^○) | ||
| + | - utilisation d' | ||
| + | - 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/ | ||
| + | ``` | ||
| + | From b2bca483212f04b9b021753aec1fcaeaf41385d1 Mon Sep 17 00:00:00 2001 | ||
| + | From: Ming Yang < | ||
| + | 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, | ||
| + | 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(" | ||
| + | Signed-off-by: | ||
| + | Signed-off-by: | ||
| + | https:// | ||
| + | --- | ||
| + | | ||
| + | 1 file changed, 10 insertions(+), | ||
| + | |||
| + | 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-> | ||
| + | - 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, | ||
| + | + return -1; | ||
| + | + } | ||
| + | | ||
| + | } | ||
| + | |||
| + | -- | ||
| + | 2.33.0 | ||
| + | ``` | ||
| + | - ajout du patch au fichier de conf' des trucs à compiler : `vim qemu-7.2+dfsg/ | ||
| + | ``` | ||
| + | # Assertion failed au moment du lxc-start/ | ||
| + | 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 / | ||
| + | dpkg-buildpackage -us -uc | ||
| + | ``` | ||
| + | - Vérification : | ||
| + | ``` | ||
| + | root@Selachimorpha:/ | ||
| + | total 864740 | ||
| + | drwxr-xr-x | ||
| + | drwx------ | ||
| + | drwxr-xr-x 60 root root 4096 Mar 12 00:56 qemu-7.2+dfsg | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | ``` | ||
| + | ## 4. Test ! | ||
| + | ``` | ||
| + | cd / | ||
| + | dpkg -i *.deb | ||
| + | ``` | ||
| + | </ | ||
user/rozlav.1675375613.txt.gz · Last modified: by 127.0.0.1