3

I want to transfer a file to a QEMU based PowerPC VM (emulating Freescale's MPC8544DS). I've used buildroot to build the kernel and rootfs. I am invoking the VM like so:

qemu-system-ppc -nographic -M mpc8544ds -m 512 -kernel ~/CrossCompilation/zImage -hda ~/CrossCompilation/rootfs.cpio -append "root=/dev/sda rw" -redir tcp:2222::22

However I was not able to transfer the file and it was throwing the following logs and error:

Executing: program /usr/bin/ssh host localhost, user root, command scp -v -t ~/.
OpenSSH_6.0p1 Debian-4+deb7u2, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [::1] port 2222.
debug1: connect to address ::1 port 2222: Connection refused
debug1: Connecting to localhost [127.0.0.1] port 2222.
debug1: Connection established.
debug1: identity file ~/.ssh/id_rsa type -1
debug1: identity file ~/.ssh/id_rsa-cert type -1
debug1: identity file ~/.ssh/id_dsa type -1
debug1: identity file ~/.ssh/id_dsa-cert type -1
debug1: identity file ~/.ssh/id_ecdsa type -1
debug1: identity file ~/.ssh/id_ecdsa-cert type -1
ssh_exchange_identification: Connection closed by remote host
lost connection

I presumed that since my VM does not seem to have any physical network adapter, networking would not be possible. So I invoke QEMU like so:

/qemu-system-ppc -nographic -M mpc8544ds -m 512 -kernel ~/CrossCompilation/zImage -hda ~/CrossCompilation/rootfs.cpio -netdev user,id=network0 -device e1000,netdev=network0 -append "root=/dev/sda rw" -redir tcp:2222::22

Sill no luck. Infact doing this does not even add any new physical ethernet adapter either (as I had thought). The only 'live' adapter, like before, is the loopback adapter.

ifconfig
lo    Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:16436  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

I was earlier under the impression that perhaps this is happening as there is no ssh deamon running on the VM hence I added Dropbear to the list of target packages and it starts while the VM boots up (it shows up as part of the startup log). Yet it fails with the very same error. So obviously this does not seem to the culprit.

I am not sure if its something to do with the networking setup on my VM or perhaps something needs to be added to the rootfs (busybox).

Waiting to hear.

AjB
  • 890
  • 13
  • 34
  • Is the network interface brought up under your VM? Do an 'ifconfig -a' instead of 'ifconfig'. By default, only eth0 is brought up, and I think you named your network interface network0 instead. – Arnout Dec 05 '14 at 16:17
  • Actually I've done that and it showed quite a few adapters however it is only the loopback adapter that is showing. I've tried playing with the `interfaces` file by adding a manual entry for eth0. But apparently the VM itself doesn't seem to have an actual eth0. – AjB Dec 06 '14 at 03:52
  • Indeed, it is named differently. I don't know how it's named, however. Perhaps you can post the list of interfaces? – Arnout Dec 08 '14 at 08:39
  • did you try `-net nic -net tap` ? This will create a `tapX` in host, wich you could configure by `ifconfig`... – F. Hauri - Give Up GitHub Apr 12 '15 at 18:39
  • Oh great yes I can see that interface now. So does one tell ssh to connect to port 2222 via this new tap0 iface? If yes how does one go about it? – AjB Apr 12 '15 at 18:43
  • I've assigned it an IP address of 10.1.2.3/24. The interface shows UP and RUNNING on the host. However when I try to connect to it from the host, it comes up as connection refused. My guest is running dropbear sshd (if that matters) – AjB Apr 12 '15 at 18:54

2 Answers2

1

If you don't have a network adapter, the best thing to do would be mount a shared drive. This page has some info on creating and modifying disks with an ARM1176JZF-S system:

http://xecdesign.com/working-with-qemu/

Steve Tauber
  • 9,551
  • 5
  • 42
  • 46
  • Well..thanks for the link although it does not talk anything about internetworking between hosts and guests.. – AjB Dec 03 '14 at 13:19
  • You'll want to create a drive on the host machine, add files, then demount it and then mount it on the VM. – Steve Tauber Dec 04 '14 at 11:40
  • I created the new disk image and mounted it. Then I copied my module binary to it followed by un-mounting it. I added the additional disk to the qemu VM by including a `-hdb 'name of disk'` in the command line invokation. However I cannot see it mounted anywhere. Nor can I see it anywhere within the `/dev` directory. I believe it should either show up as `/dev/hdb` or `/dev/sdb`. Am I right here? What could have gone wrong? – AjB Dec 13 '14 at 09:13
0

Tested on Buildroot 2016.05, QEMU 2.5.0 x86_64, Ubuntu 16.04 host

I'm not into ppc, but this should work there as well. Let me know if not.

Start with qemu_x86_64_defconfig and enable the openssh package.

Start QEMU with:

qemu-system-x86_64 \
  -M pc \
  -append root=/dev/vda \
  -drive file=output/images/rootfs.ext2,if=virtio,format=raw \
  -enable-kvm \
  -kernel output/images/bzImage \
  -m 512 \
  -net nic,model=virtio \
  -net user,hostfwd=tcp::2222-:22

Then on guest:

vi /etc/ssh/sshd_config

Modify the following settings:

PermitRootLogin yes
PermitEmptyPassword yes

And restart the server:

/etc/init.d/50sshd restart

It is because this file exists that sshd starts by default.

Then from host:

ssh root@localhost -p 2222

In case of failure, also check the server logs on guest:

less /var/log/messages

Then on the final system you should automate the creation of that log file with BR2_ROOTFS_OVERLAY or BR2_ROOTFS_POST_BUILD_SCRIPT: https://buildroot.org/downloads/manual/manual.html#rootfs-custom

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985