On 11/27/2013 12:52 PM, mars(a)linux.vnet.ibm.com wrote:
From: Bing Bu Cao <mars(a)linux.vnet.ibm.com>
virsh command 'domxml-to-native' did not copy the
MAC address which parsed from a domain xml, in the commandline
the MAC addr of network device always was 00:00:00:00:00:00.
This patch fix it.
Signed-off-by: Bing Bu Cao <mars(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8a1eefd..4693dad 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);
@@ -5843,6 +5844,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->script = NULL;
net->data.ethernet.dev = brnamecopy;
net->data.ethernet.ipaddr = NULL;
+ net->mac = mac;
Actually you don't need to put this same statement in all the clauses of
the conditional. Instead, you can just put it in a single place - where
the saved net->model is restored. Even in the case that none of the
clauses of the conditional were taken, it would just lead to the same
value being copied over itself, which is effectively a NOP, so no harm done.
I've made that change, added a bit more explanation to the commit log
message, and pushed the result.
Thanks for pointing this out and sending the patch!
} else {
/* actualType is either NETWORK or DIRECT. In either
* case, the best we can do is NULL everything out.
@@ -5854,6 +5856,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->script = NULL;
net->data.ethernet.dev = NULL;
net->data.ethernet.ipaddr = NULL;
+ net->mac = mac;
}
} else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
VIR_FREE(net->data.direct.linkdev);
@@ -5864,6 +5867,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->script = NULL;
net->data.ethernet.dev = NULL;
net->data.ethernet.ipaddr = NULL;
+ net->mac = mac;
} else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
char *script = net->script;
char *brname = net->data.bridge.brname;
@@ -5875,6 +5879,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->script = script;
net->data.ethernet.dev = brname;
net->data.ethernet.ipaddr = ipaddr;
+ net->mac = mac;
}
VIR_FREE(net->virtPortProfile);