How to get files into a Qemu VM


Picture the scene, you have created a Windows VM for use in UNetLab. You loaded it with all your go-to applications, and are good to go.

A week or so down the line you have a new requirement, that demands a certain application to be loaded on to the VM.

What do you do? Delete the VM and recreate it? That would be a waste of a license. VNC doesn't handle cut and paste, and you can't get it connected to your internal network in order to download it.

I had this issue today. For a post on how to run Barracuda NG Firewall in UNetLab, I needed to run the NGAdmin program. But the pnet0 interface wouldn't play ball, and I can't cut and paste form my Mac into the VNC.

So, I mulled over my options for a moment, then realised that I could copy the files I needed to the /tmp/ directory on the UNetLab box and make an ISO of that folder. This can then be used by the Qemu guest as a standard CDRom!
UNetLab does not come with the mkisofs program by default, so you'll need to install this:
root@unl01:~# sudo apt-get install mkisofs
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'genisoimage' instead of 'mkisofs'
The following packages were automatically installed and are no longer required:
  linux-headers-3.13.0-61 linux-headers-3.13.0-61-generic
  linux-headers-3.13.0-62 linux-headers-3.13.0-62-generic
  linux-image-3.13.0-61-generic linux-image-3.13.0-62-generic
Use 'apt-get autoremove' to remove them.
Suggested packages:
  wodim cdrkit-doc
The following NEW packages will be installed:
  genisoimage
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 587 kB of archives.
After this operation, 1,580 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main genisoimage amd64 9:1.1.11-2ubuntu3 [587 kB]
Fetched 587 kB in 0s (840 kB/s)
Selecting previously unselected package genisoimage.
(Reading database ... 129086 files and directories currently installed.)
Preparing to unpack .../genisoimage_9%3a1.1.11-2ubuntu3_amd64.deb ...
Unpacking genisoimage (9:1.1.11-2ubuntu3) ...
Setting up genisoimage (9:1.1.11-2ubuntu3) ...
root@unl01:~#
You will need to make sure that the exe file is on your UNetLab machine:
root@unl01:~# ls /tmp/
netio32768  ngadmin_6-1-0-150 (1).exe  vmware-root
root@unl01:~# cd /tmp/
It's there, so let's make a fiolder and copy it into it:
root@unl01:/tmp# mkdir Barracuda
root@unl01:/tmp# mv ngadmin_6-1-0-150\ \(1\).exe Barracuda/
Now we can create a cdrom image in the win-7-pro directory, called cdrom.iso (do not name it anything other than this), using the folder /tmp/Barracuda as the source:
root@unl01:/tmp# mkisofs -o /opt/unetlab/addons/qemu/win-7-Pro/cdrom.iso /tmp/Barracuda/
I: -input-charset not specified, using utf-8 (detected in locale settings)
 47.84% done, estimate finish Tue Sep  8 10:42:26 2015
 95.75% done, estimate finish Tue Sep  8 10:42:26 2015
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 116
Path table size(bytes): 10
Max brk space used 0
10452 extents written (20 MB)
root@unl01:/tmp#
Now we can turn on the Windows VM and access the CDRom drive. If the VM was turned on before the cdrom.iso file was copied to the directory then shut it down and start it up again.

Qemu CD ROM, how to get files into Qemu guest

Bingo, the CD Rom is there. And so are my much needed files:

Qemu - working CDrom

CCIE #49337, author of CCNA and Beyond, BGP for Cisco Networks, MPLS for Cisco Networks, VPNs and NAT for Cisco Networks.

Related Posts

Previous
Next Post »

3 comments

comments
7 October 2015 at 10:02 delete

Hi Stuart, I have problem with Windows nodes in unetlab. Windows nodes dont have sound device in unetlab. So cisco softphone dont start without sound driver. How can we add sound driver to windows qemu?
Please help. Thank you

Reply
avatar
7 October 2015 at 10:55 delete

I have no idea! "qemu sound windows 7" brings up some good suggestions. I havnt tried any of them though.

Reply
avatar
7 October 2015 at 13:22 delete

Can you try it? I dont have enough skills about linux and qemu.
I think i need something like this command:
opt/qemu/bin/qemu-system-x86_64 -enable-Kvm -vnc :1 -soundhw ac97 -nographic -boot order = c, once = d -smp 1 -m 2048 -usb -hda /opt/unetlab/addons/qemu/win-7/hda.qcow2
Or like this:
QEMU_AUDIO_DRV=alsa /opt/qemu-2.0.2/bin/qemu-system-x86_64 -vnc :1 -nographic -boot order=c,once=d -smp 1 -m 2048 -usb -hda hda.qcow2.
I dont know, maybe it is just a question "how to add sound driver to qemu". Google replied me some, but because of the lack of skills, i could not solve the problem.
I just need someone to try it.

Reply
avatar