From 8e043864ecd32cd402176308d00ced8e8a15f758 Mon Sep 17 00:00:00 2001 From: Bing Bu Cao Date: Wed, 27 Nov 2013 18:52:12 +0800 Subject: [PATCH] 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 Signed-off-by: Laine Stump --- src/qemu/qemu_driver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8a1eefdd39..47d8a09d02 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5821,6 +5821,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, virDomainNetDefPtr net = def->nets[i]; int bootIndex = net->info.bootIndex; char *model = net->model; + virMacAddr mac = net->mac; if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) { int actualType = virDomainNetGetActualType(net); @@ -5880,6 +5881,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, VIR_FREE(net->virtPortProfile); net->info.bootIndex = bootIndex; net->model = model; + net->mac = mac; } monitor_json = virQEMUCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON); -- GitLab