fix network booting when using "-device" instead of "-net nic"
cover fix network booting when using "-device" instead of "-net nic"
This series fixes the following issue:
$ qemu-system-x86_64 -device rtl8139,vlan=0,id=net0,mac=52:54:00:82:41:fd,bus=pci.0,addr=0x4 -net user,vlan=0,name=hostnet0 -vnc 0.0.0.0:0 -boot n Cannot boot from non-existent NIC $
Patches 1 and 3 are just cleanups. The actual fix is on patch 2.
Eduardo Habkost (3):
Kill NICInfo.bootable field
kill broken net_set_boot_mask() boot device validation kill unused boot_devices_bitmap variable
net.c | 20 -------------------- net.h | 2 -- vl.c | 13 ++++--------- 3 files changed, 4 insertions(+), 31 deletions(-)
PATCH 1/3 net: remove NICInfo.bootable field
It is just set by net_set_boot_mask() and never used. The logic for rom loading changed a lot since this field was introduced. It is not needed anymore.
--- net.c | 1 - net.h | 1 - 2 files changed, 0 insertions(+), 2 deletions(-)
net.c +0 -1
@@ -1207,7 +1207,6 @@ void net_set_boot_mask(int net_boot_mask)for (i =0 ; i < nb_nics; i++) {if (net_boot_mask & (1 << i)) { - nd_table[i].bootable =1 ; net_boot_mask &= ~(1 << i); } }
net.h +0 -1
@@ -132,7 +132,6 @@ struct NICInfo {VLANState *vlan;VLANClientState *netdev;int used; -int bootable;int nvectors; };
Signature · 1 line
1.7.0.3
PATCH 2/3 net: remove broken net_set_boot_mask() boot device validation
In reply to Eduardo HabkostThere are many problems with net_set_boot_mask():
1) It is broken when using the device model instead of "-net nic". Example:
$ qemu-system-x86_64 -device rtl8139,vlan=0,id=net0,mac=52:54:00:82:41:fd,bus=pci.0,addr=0x4 -net user,vlan=0,name=hostnet0 -vnc 0.0.0.0:0 -boot n Cannot boot from non-existent NIC $ 2) The mask was previously used to set which boot ROMs were supposed to be loaded, but this was changed long time ago. Now all ROM images are loaded, and SeaBIOS takes care of jumping to the right boot entry point depending on the boot settings. 3) Interpretation and validation of the boot parameter letters is done on the machine type code. Examples: PC accepts only a,b,c,d,n as valid boot device letters. mac99 accepts only a,b,c,d,e,f.
As a side-effect of this change, qemu-kvm won't abort anymore if using "-boot n" on a machine with no network devices. Checking if the requested boot device is valid is now a task for the BIOS or the machine-type code.
--- net.c | 19 ------------------- net.h | 1 - vl.c | 5 +---- 3 files changed, 1 insertions(+), 24 deletions(-)
net.c +0 -19
@@ -1198,25 +1198,6 @@ void net_host_device_remove(Monitor *mon, const QDict *qdict)qemu_del_vlan_client (vc); } -void net_set_boot_mask (int net_boot_mask) -{ -int i; - -/* Only the first four NICs may be bootable */ - net_boot_mask = net_boot_mask &0xF ; - -for (i =0 ; i < nb_nics; i++) { -if (net_boot_mask & (1 << i)) { - net_boot_mask &= ~(1 << i); - } - } - -if (net_boot_mask) { -fprintf (stderr,"Cannot boot from non-existent NIC\n" ); -exit (1 ); - } -} -void do_info_network (Monitor *mon) {VLANState *vlan;
net.h +0 -1
@@ -162,7 +162,6 @@ int net_client_parse(QemuOptsList *opts_list, const char *str);int net_init_clients (void );void net_check_clients (void );void net_cleanup (void ); -void net_set_boot_mask (int boot_mask);void net_host_device_add (Monitor *mon,const QDict *qdict);void net_host_device_remove (Monitor *mon,const QDict *qdict);
vl.c +1 -4
@@ -2621,7 +2621,7 @@ int main(int argc, char **argv, char **envp)const char *gdbstub_dev =NULL ;uint32_t boot_devices_bitmap =0 ;int i; -int snapshot, linux_boot, net_boot; +int snapshot, linux_boot;const char *icount_option =NULL ;const char *initrd_filename;const char *kernel_filename, *kernel_cmdline;
@@ -3630,9 +3630,6 @@ int main(int argc, char **argv, char **envp)exit (1 ); } - net_boot = (boot_devices_bitmap >> ('n' -'a' )) &0xF ; -net_set_boot_mask (net_boot); -/* init the bluetooth world */ if (foreach_device_config (DEV_BT , bt_parse))exit (1 );
Signature · 1 line
1.7.0.3
PATCH 3/3 boot: remove unused boot_devices_bitmap variable
In reply to Eduardo HabkostIn addition to removing the variable, this also renames the parse_bootdevices() function to validate_bootdevices(), as we don't need its return value anymore.
--- vl.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
vl.c +3 -5
@@ -1246,7 +1246,7 @@ int qemu_boot_set(const char *boot_devices)return boot_set_handler (boot_set_opaque, boot_devices); } -static int parse_bootdevices (char *devices) +static void validate_bootdevices (char *devices) {/* We just do some generic consistency checks */ const char *p;
@@ -1272,7 +1272,6 @@ static int parse_bootdevices(char *devices) } bitmap |=1 << (*p -'a' ); } -return bitmap; }static void restore_boot_devices (void *opaque)
@@ -2619,7 +2618,6 @@ static const QEMUOption *lookup_opt(int argc, char **argv,int main (int argc,char **argv,char **envp) {const char *gdbstub_dev =NULL ; -uint32_t boot_devices_bitmap =0 ;int i;int snapshot, linux_boot;const char *icount_option =NULL ;
@@ -2938,13 +2936,13 @@ int main(int argc, char **argv, char **envp)if (legacy ||get_param_value (buf,sizeof (buf),"order" , optarg)) { - boot_devices_bitmap =parse_bootdevices (buf); +validate_bootdevices (buf);pstrcpy (boot_devices,sizeof (boot_devices), buf); }if (!legacy) {if (get_param_value (buf,sizeof (buf),"once" , optarg)) { - boot_devices_bitmap |=parse_bootdevices (buf); +validate_bootdevices (buf); standard_boot_devices =qemu_strdup (boot_devices);pstrcpy (boot_devices,sizeof (boot_devices), buf); qemu_register_reset(restore_boot_devices,
Signature · 1 line
1.7.0.3
Quoted 7 lines · Eduardo Habkost
This series fixes the following issue:
$ qemu-system-x86_64 -device rtl8139,vlan=0,id=net0,mac=52:54:00:82:41:fd,bus=pci.0,addr=0x4 -net user,vlan=0,name=hostnet0 -vnc 0.0.0.0:0 -boot n Cannot boot from non-existent NIC $Patches 1 and 3 are just cleanups. The actual fix is on patch 2.
Nice cleanup. It just removes dead code that was hurting.
Quoted 7 lines · Eduardo Habkost
This series fixes the following issue:
$ qemu-system-x86_64 -device rtl8139,vlan=0,id=net0,mac=52:54:00:82:41:fd,bus=pci.0,addr=0x4 -net user,vlan=0,name=hostnet0 -vnc 0.0.0.0:0 -boot n Cannot boot from non-existent NIC $Patches 1 and 3 are just cleanups. The actual fix is on patch 2.
Thanks, all applied.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net