Description of problem: virsh domxml-to-native returns invalid MAC address for a VM. Below is a snip of the n/w interface in the VM. <interface type='network'> <mac address='52:54:00:70:04:ad'/> <source network='default'/> <target dev='vnet3'/> <model type='virtio'/> <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> However, when we use the command "virsh domxml-to-native", the MAC is displayed as:00:00:00:00:00:00 virsh domxml-to-native qemu-argv /etc/libvirt/qemu/santwana-test.xml LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin QEMU_AUDIO_DRV=none /bin/qemu-system-x86_64 -name santwana-test -S -machine pc-i440fx-1.6,accel=kvm,usb=off -m 1200 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 6573f348-b74f-a587-6f8e-445dd09b435c -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/santwana-test.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/home/santwanaguest.img,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive if=none,id=drive-ide0-1-0,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,id=hostnet0,vhost=on,vhostfd=28 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:00:00:00:00:00,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:0 -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 Version-Release number of selected component (if applicable): rpm -qa|grep libvirt libvirt-client-1.0.5.1-1.fc19.x86_64 libvirt-glib-0.1.6-1.fc19.x86_64 libvirt-glib-devel-0.1.6-1.fc19.x86_64 libvirt-python-1.0.5.1-1.fc19.x86_64 How reproducible: Always Steps to Reproduce: 1. Convert the domain XML to native config using virsh domxml-to-native. 2. Even though the guest has an valid MAC assigned, the output of MAC in the result is invalid. Actual results: LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin QEMU_AUDIO_DRV=none /bin/qemu-system-x86_64 -name santwana-test -S -machine pc-i440fx-1.6,accel=kvm,usb=off -m 1200 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 6573f348-b74f-a587-6f8e-445dd09b435c -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/santwana-test.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/home/santwanaguest.img,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive if=none,id=drive-ide0-1-0,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,id=hostnet0,vhost=on,vhostfd=28 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:00:00:00:00:00,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:0 -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 Expected results: LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin QEMU_AUDIO_DRV=none /bin/qemu-system-x86_64 -name santwana-test -S -machine pc-i440fx-1.6,accel=kvm,usb=off -m 1200 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 6573f348-b74f-a587-6f8e-445dd09b435c -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/santwana-test.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/home/santwanaguest.img,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive if=none,id=drive-ide0-1-0,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,id=hostnet0,vhost=on,vhostfd=28 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:70:04:ad,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:0 -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 Additional info:
Fixed in libvirt upstream: commit 8e043864ecd32cd402176308d00ced8e8a15f758 Author: Bing Bu Cao <mars.ibm.com> Date: Wed Nov 27 18:52:12 2013 +0800 qemu: preserve netdev MAC address during 'domxml-to-native' The virsh command 'domxml-to-native' (virConnectDomainXMLToNative()) converts all network devices to "type='ethernet'" in order to make it more likely that the generated command could be run directly from a shell (other libvirt network device types end up referencing file descriptors for tap devices assumed to have been created by libvirt, which can't be done in this case). During this conversion, all of the netdev parameters are cleared out, then specific items are filled in after changing the type. The MAC address was not one of these preserved items, and the result was that mac addresses in the generated commandlines were always 00:00:00:00:00:00. This patch saves the mac address before the conversion, then repopulates it afterwards, so the proper mac addresses show up in the commandline. Signed-off-by: Bing Bu Cao <mars.ibm.com> Signed-off-by: Laine Stump <laine>