summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2011-07-19 15:37:32 -0700
committerRobert Mustacchi <rm@joyent.com>2011-07-19 15:37:32 -0700
commit4fcc2a648f76542e90fb6a3d413ac5548be37d0d (patch)
tree3b71a7ca058ec9fca42535dd8aabe915343c3b4f
parent9b7f494e46eac4f49cf348415723fcf43def27f1 (diff)
downloadillumos-kvm-cmd-4fcc2a648f76542e90fb6a3d413ac5548be37d0d.tar.gz
HVM-496 If -net vnic is not passed a mac address, it should be able to use the existing MAC address on the vnic
-rw-r--r--README.illumos4
-rw-r--r--net/vnic.c32
2 files changed, 20 insertions, 16 deletions
diff --git a/README.illumos b/README.illumos
index b458158..b07b7cc 100644
--- a/README.illumos
+++ b/README.illumos
@@ -52,8 +52,8 @@ directly correspond to a Crossbow vnic on the system. The -net vnic has several
mandatory arguments:
* vlan must be specified and correspond to a single -net nic line
* name must be specified and correspond to a single -net nic line
- * macaddr must be specified and correspond to a single -net nic line. This
- is the mac address that the vnic will use.
+ * macaddr must be specified if the MAC Address of the VNIC does not match
+ the MAC address on the -net nic line.
* ifname must be specified and correspond to the name of the crossbow vnic.
To set up the crossbow vnic, simply create it. There is no need to plumb it.
diff --git a/net/vnic.c b/net/vnic.c
index aca3106..b313550 100644
--- a/net/vnic.c
+++ b/net/vnic.c
@@ -255,15 +255,14 @@ net_init_vnic(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
return (-1);
}
- if ((mac = qemu_opt_get(opts, "macaddr")) == NULL) {
- error_report("missing macaddr required for vnic\n");
- return (-1);
- }
-
- macaddr = _link_aton(mac, &len);
- if (macaddr == NULL || len != ETHERADDRL) {
- error_report("invalid macaddr for vnic: %s\n", mac);
- return (-1);
+ mac = qemu_opt_get(opts, "macaddr");
+
+ if (mac != NULL) {
+ macaddr = _link_aton(mac, &len);
+ if (macaddr == NULL || len != ETHERADDRL) {
+ error_report("invalid macaddr for vnic: %s\n", mac);
+ return (-1);
+ }
}
ncp = qemu_new_net_client(&net_vnic_info, vlan, NULL, "vnic", name);
@@ -279,11 +278,16 @@ net_init_vnic(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
return (-1);
}
- assert(len == ETHERADDRL);
- if (dlpi_set_physaddr(vsp->vns_hdl, DL_CURR_PHYS_ADDR, macaddr,
- ETHERADDRL) != DLPI_SUCCESS) {
- error_report("vnic: failed to set mac address\n");
- return (-1);
+ /*
+ * We only set the mac address of the vnic if the user passed in the
+ * option on the command line.
+ */
+ if (mac != NULL) {
+ if (dlpi_set_physaddr(vsp->vns_hdl, DL_CURR_PHYS_ADDR, macaddr,
+ ETHERADDRL) != DLPI_SUCCESS) {
+ error_report("vnic: failed to set mac address\n");
+ return (-1);
+ }
}
if (dlpi_promiscon(vsp->vns_hdl, DL_PROMISC_SAP) != DLPI_SUCCESS) {