Unverified Commit f171f970 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Disable kernel networking in bridge mode (#449)

parent 0100fb6c
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -4,14 +4,9 @@ services:
    container_name: qemu
    image: qemux/qemu-docker
    environment:
      RAM_SIZE: "1G"
      CPU_CORES: "1"
      DISK_SIZE: "16G"
      BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso"
    devices:
      - /dev/kvm
    device_cgroup_rules:
      - 'c *:* rwm'
    cap_add:
      - NET_ADMIN
    ports:
+2 −0
Original line number Diff line number Diff line
@@ -169,6 +169,8 @@ docker run -it --rm --name qemu -e "BOOT=http://example.com/image.iso" -p 8006:8
  ```yaml
  environment:
    DHCP: "Y"
  devices:
    - /dev/vhost-net
  device_cgroup_rules:
    - 'c *:* rwm'
  ```
+11 −9
Original line number Diff line number Diff line
@@ -25,8 +25,14 @@ ADD_ERR="Please add the following setting to your container:"

configureDHCP() {

  # Create a macvtap network for the VM guest
  # Create the necessary file structure for /dev/vhost-net
  if [ ! -c /dev/vhost-net ]; then
    if mknod /dev/vhost-net c 10 238; then
      chmod 660 /dev/vhost-net
    fi
  fi

  # Create a macvtap network for the VM guest
  { ip link add link "$VM_NET_DEV" name "$VM_NET_TAP" address "$VM_NET_MAC" type macvtap mode bridge ; rc=$?; } || :

  if (( rc != 0 )); then
@@ -188,8 +194,10 @@ configureNAT() {

  NET_OPTS="-netdev tap,ifname=$VM_NET_TAP,script=no,downscript=no,id=hostnet0"

  if [ -c /dev/vhost-net ]; then
    { exec 40>>/dev/vhost-net; rc=$?; } 2>/dev/null || :
    (( rc == 0 )) && NET_OPTS="$NET_OPTS,vhost=on,vhostfd=40"
  fi

  configureDNS

@@ -279,12 +287,6 @@ if [[ "$NETWORK" != [Yy1]* ]]; then
  return 0
fi

if [ ! -c /dev/vhost-net ]; then
  if mknod /dev/vhost-net c 10 238; then
    chmod 660 /dev/vhost-net
  fi
fi

getInfo
html "Initializing network..."