Hi all,

This patch fixes an issue when net booting GRUB with QEMU. It was made by Avik Sil, a colleague from IBM.

QEMU uses the local-mac-address property to store the mac address but it uses a 64bit property for it. This patch makes a proper treatment.

To illustrate, this is the property from our tests:

0 > dev /vdevice/l-lan@71000002   ok
0 > .properties
...
local-mac-address                00005254  00123456
...

--
Paulo Flabiano Smorigo
Software Engineer
Linux Technology Center - IBM Systems & Technology Group
=== modified file 'ChangeLog'
--- ChangeLog	2013-08-14 09:10:09 +0000
+++ ChangeLog	2013-08-14 13:35:34 +0000
@@ -1,3 +1,8 @@
+2013-08-14 Avik Sil <avik...@in.ibm.com>
+
+	* grub-core/net/drivers/ieee1275/ofnet.c: Get proper mac address when
+	using qemu.
+
 2013-08-14  Vladimir Serbinenko  <phco...@gmail.com>
 
 	* include/grub/i386/pc/biosdisk.h (grub_biosdisk_drp): Fix device_path

=== modified file 'grub-core/net/drivers/ieee1275/ofnet.c'
--- grub-core/net/drivers/ieee1275/ofnet.c	2013-04-13 18:12:11 +0000
+++ grub-core/net/drivers/ieee1275/ofnet.c	2013-08-14 13:30:17 +0000
@@ -202,6 +202,8 @@
   struct grub_net_card *card;
   grub_ieee1275_phandle_t devhandle;
   grub_net_link_level_address_t lla;
+  grub_ssize_t prop_size;
+  grub_uint8_t prop_array[8], *pprop;
   char *shortname;
 
   if (grub_strcmp (alias->type, "network") != 0)
@@ -235,16 +237,20 @@
       card->mtu = t;
   }
 
+  pprop = &prop_array[0];
   if (grub_ieee1275_get_property (devhandle, "mac-address",
 				  &(lla.mac), 6, 0)
       && grub_ieee1275_get_property (devhandle, "local-mac-address",
-				     &(lla.mac), 6, 0))
+				     pprop, 8, &prop_size))
     {
       grub_error (GRUB_ERR_IO, "Couldn't retrieve mac address.");
       grub_print_error ();
       return 0;
     }
 
+  if (prop_size == 8) {
+    grub_memcpy(&lla.mac, &prop_array[2], 6);
+  }
   lla.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
   card->default_address = lla;
 

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to