最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【未解决】Ubuntu下用QEMU启动内核时出错:SIOCSIFADDR: No such device

QEMU crifan 5932浏览 0评论

【问题】

折腾:

【记录】Ubuntu下使用QEMU启动Linux内核

期间,虽然已经解决了:

【已解决】Ubuntu下QEMU启动内核时出错:/etc/qemu-ifup: 19: /etc/qemu-ifup: /usr/sbin/openvpn: not found

但是还是有其他错误:

crifan@ubuntu:ifup_ifdown$ sudo /opt/qemu/bin/qemu-system-arm -M versatilepb -nographic -net nic -net tap,ifname=tap0 -kernel /home/crifan/develop/crosscompile/uboot/u-boot-2013.07/u-boot
/sbin/ifdown: interface eth0 not configured
SIOCSIFADDR: No such device
br0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
SIOCSIFBRDADDR: No such device
br0: ERROR while getting interface flags: No such device
SIOCADDRT: Network is unreachable
/etc/qemu-ifup: 39: /etc/qemu-ifup: /sbin/service: not found
/etc/qemu-ifup: could not launch network script
qemu-system-arm: -net tap,ifname=tap0: Device 'tap' could not be initialized

SIOCSIFADDR: No such device

【解决过程】

1.参考:

Playing with qemu

说是要有个ne2k-pci的模块。

2.参考:

Re: [Qemu-devel] Setting up tun/tap network doesn’t work

好像说是,是linux guest,即qemu里面的那个linux需要ne2k-pci驱动。

(而不是我当前的Ubuntu)

3。然后参考:

透過虛擬化技術體驗 kgdb (1)

也说是,需要重新编译kernel,加上“NIC device driver ”。

所以就去重新配置kernel:

crifan@ubuntu:linux-3.10.7$ make ARCH=arm CROSS_COMPILE=arm-xscale-linux-gnueabi- menuconfig
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/mconf.o
  HOSTLD  scripts/kconfig/mconf
scripts/kconfig/mconf Kconfig

加上对应的nic:

4.结果是找了半天,menuconfig里面也没找到NIC device driver。

5。但是貌似里面是有关于:

Device Drivers > Network device support -> Universal TUN/TAP device driver support

的配置的,之前没有选上,现在去选上:

Universal TUN TAP device driver support

对应的配置是:

.config – Linux/arm 3.10.7 Kernel Configuration

> Device Drivers > Network device support

   Universal TUN/TAP device driver support

  │ CONFIG_TUN:                                                         
  │                                                                     
  │ TUN/TAP provides packet reception and transmission for user space   
  │ programs.  It can be viewed as a simple Point-to-Point or Ethernet  
  │ device, which instead of receiving packets from a physical media,   
  │ receives them from user space program and instead of sending packets

  │ via physical media writes them to the user space program.           
  │                                                                     
  │ When a program opens /dev/net/tun, driver creates and registers     
  │ corresponding net device tunX or tapX.  After a program closed above

  │ devices, driver will automatically delete tunXX or tapXX device and 
  │ all routes corresponding to it.                                     
  │                                                                     
  │ Please read <file:Documentation/networking/tuntap.txt> for more     
  │ information.                                                        
  │                                                                     
  │ To compile this driver as a module, choose M here: the module       
  │ will be called tun.                                                 
  │                                                                     
  │ If you don’t know what to use this for, you don’t need it.          
  │                                                                     
  │ Symbol: TUN [=y]                                                    
  │ Type  : tristate                                                    
  │ Prompt: Universal TUN/TAP device driver support                     
  │   Location:                                                         
  │     -> Device Drivers                                               
  │       -> Network device support (NETDEVICES [=y])                   
  │         -> Network core driver support (NET_CORE [=y])              
  │   Defined at drivers/net/Kconfig:210                                
  │   Depends on: NETDEVICES [=y] && NET_CORE [=y]                      
  │   Selects: CRC32 [=y]

6.然后重新编译:

make ARCH=arm CROSS_COMPILE=arm-xscale-linux-gnueabi- uImage

crifan@ubuntu:linux-3.10.7$ make ARCH=arm CROSS_COMPILE=arm-xscale-linux-gnueabi- uImage
scripts/kconfig/conf --silentoldconfig Kconfig
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CC      scripts/mod/devicetable-offsets.s
  GEN     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTLD  scripts/mod/modpost
  CHK     include/generated/compile.h
  CC      drivers/net/tun.o
  LD      drivers/net/built-in.o
  LD      drivers/built-in.o
  CC      net/socket.o
  LD      net/built-in.o
  LINK    vmlinux
  LD      vmlinux.o
  MODPOST vmlinux.o
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  OBJCOPY arch/arm/boot/Image
  Kernel: arch/arm/boot/Image is ready
  GZIP    arch/arm/boot/compressed/piggy.gzip
  AS      arch/arm/boot/compressed/piggy.gzip.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
Image Name:   Linux-3.10.7
Created:      Sun Aug 18 21:50:41 2013
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    1898744 Bytes = 1854.24 kB = 1.81 MB
Load Address: 00008000
Entry Point:  00008000
  Image arch/arm/boot/uImage is ready
crifan@ubuntu:linux-3.10.7$ 

然后再去运行试试,结果错误依旧:

crifan@ubuntu:ifup_ifdown$ sudo /opt/qemu/bin/qemu-system-arm -M versatilepb -nographic -net nic -net tap,ifname=tap0 -kernel /home/crifan/develop/crosscompile/uboot/u-boot-2013.07/u-boot
/sbin/ifdown: interface eth0 not configured
SIOCSIFADDR: No such device
br0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
SIOCSIFBRDADDR: No such device
br0: ERROR while getting interface flags: No such device
SIOCADDRT: Network is unreachable
/etc/qemu-ifup: 39: /etc/qemu-ifup: /sbin/service: not found
/etc/qemu-ifup: could not launch network script
qemu-system-arm: -net tap,ifname=tap0: Device 'tap' could not be initialized

此时,才注意到,此刻,根本就还没去加载uImage呢,而只是针对于-kernel给的是u-boot,即:

此处的错误,和uImage,没有任何关系,而只是QEMU哪里没配置好或者是当前Ubuntu哪里配置不支持,而导致的错误。

7.参考:

虚拟机备份转移后,网络启动异常,提示“SIOCSIFADDR: No such device”的解决方案

去试试ping和重启,结果(貌似是)正常的:

crifan@ubuntu:ifup_ifdown$ ping www.baidu.com
ping: unknown host www.baidu.com
crifan@ubuntu:ifup_ifdown$ sudo /etc/init.d/networking
networking           networking.dpkg-new  
crifan@ubuntu:ifup_ifdown$ sudo /etc/init.d/networking restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service networking restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop networking ; start networking. The restart(8) utility is also available.
networking stop/waiting
networking start/running
crifan@ubuntu:ifup_ifdown$ 

【总结】

暂时没有解决此问题。

暂时放弃此问题。

因为,觉得,之前看到的:

QEMU/Networking

自己此处,没有完全符号要求,所以才会在网络方面出现问题。

所以,打算参考上述教程,去弄好网络配置后,再去折腾此问题。

转载请注明:在路上 » 【未解决】Ubuntu下用QEMU启动内核时出错:SIOCSIFADDR: No such device

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (2)

  1. 你的问题可能是model选错了导致的,你试试添加model参数 -net nic,model=pcnet -net tap,ifname=tap0,script=no,downscript=no -net nic,model=? //查询qemu支持的虚拟网卡,但结果的有些网卡可能并不支持 参考 http://blog.csdn.net/shendl/article/details/9468227
    wukun11年前 (2014-02-13)回复
    • 谢谢,等我以后有空再去试试。
      crifan11年前 (2014-02-17)回复
88 queries in 0.211 seconds, using 22.27MB memory