Add remove_boot_device_path() function for hot-unplug device
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 117 lines · Marcel Apfelbaum
Quoted 101 lines · Jun Li
Add
remove_boot_device_path()function to remove bootindex when hot-unplug a device. This patch fixed virtio-blk/virtio-net/scsi-disk/scsi-generic device. So it has fixed bug1086603, ref:
https://bugzilla.redhat.com/show_bug.cgi?id=1086603Make some changes based on Andreas's good suggestion.
Signed-off-by Jun Li <[email protected]>--- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 1 + hw/scsi/scsi-disk.c | 6 ++++-- hw/scsi/scsi-generic.c | 3 +++ include/sysemu/sysemu.h | 2 ++ vl.c | 16 ++++++++++++++++ 6 files changed, 27 insertions(+), 2 deletions(-)hw/block/virtio-blk.c +1
-0@@ -752,6 +752,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)unregister_savevm (dev,"virtio-blk" , s);blockdev_mark_auto_del (s->bs);virtio_cleanup (vdev); +remove_boot_device_path (s->conf->bootindex, dev,"/disk@0,0" ); }static Property virtio_blk_properties[] = {hw/net/virtio-net.c +1
-0@@ -1633,6 +1633,7 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)g_free (n->vqs);qemu_del_nic (n->nic);virtio_cleanup (vdev); +remove_boot_device_path (n->nic_conf.bootindex, dev,"/ethernet-phy@0" ); }static void virtio_net_instance_init (Object *obj)hw/scsi/scsi-disk.c +4
-2@@ -2150,12 +2150,14 @@ static void scsi_disk_reset(DeviceState *dev) s->tray_open =0 ; } -static void scsi_destroy (SCSIDevice *dev) +static void scsi_destroy (SCSIDevice *sdev) { -SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, dev); +SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, sdev); +DeviceState *dev =DEVICE (sdev);scsi_device_purge_requests (&s->qdev,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->qdev.conf.bs); +remove_boot_device_path (s->qdev.conf.bootindex, dev,NULL ); }static void scsi_disk_resize_cb (void *opaque)hw/scsi/scsi-generic.c +3
-0@@ -388,8 +388,11 @@ static void scsi_generic_reset(DeviceState *dev)static void scsi_destroy (SCSIDevice *s) { +DeviceState *dev =DEVICE (s); +scsi_device_purge_requests (s,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->conf.bs); +remove_boot_device_path (s->conf.bootindex, dev,NULL ); }static int scsi_generic_initfn (SCSIDevice *s)include/sysemu/sysemu.h +2
-0@@ -193,6 +193,8 @@ void rtc_change_mon_event(struct tm *tm);void add_boot_device_path (int32_t bootindex,DeviceState *dev,const char *suffix); +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix);char *get_boot_devices_list (size_t *size,bool ignore_suffixes);DeviceState *get_boot_device (uint32_t position);vl.c +2
-0@@ -1184,6 +1184,22 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,QTAILQ_INSERT_TAIL (&fw_boot_order, node, link); } +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix)vl.c void add_boot_device_path(int32_t bootindex, DeviceState *dev, · line 1198
Quoted 10 lines
vl.c +10
-0+{ +FWBootEntry *node, *next_node; + +if (bootindex ==-1 ) { +return ; + } + + QTAILQ_FOREACH_SAFE(node, &fw_boot_order, link, next_node) +if (node->bootindex == bootindex) { +QTAILQ_REMOVE (&fw_boot_order, node, link);Hi Liu.
Sorry for the late response, but I was in vacation :) . Your patch looks OK, I once wrote another one on the same issue (it touched the same problem, but it was *completely* different).
Quoted 7 lines
Here is the *real* problem:
fw_boot_orderlist is not queried again on guest reboot, so 'touching' the list has no effect. While your code is correct (as far as I can tell), it seems that his place is after the above problem is solved.No one is currently working on this, feel free
to take this challenge. I'll help however I can.
Hi Marcel,
Sorry, so later response. I got a heavy sick these days. I have see these discussion emails between you and Paolo.
After guest reboot, seabios will got devices info from boards(this boards be generated by qemu command line). Just as Paolo's explanations, but I am not familiar with seabios. I will do some research about this. Thank you very much.
BTW, My first name is Jun, my last name is Li, my English name is woodpecker, you could call me jun or woodpecker. :)
Best Regards,
Jun Li
Quoted 10 lines
Quoted 8 lines
vl.c +4
-0+return ; + } +} +DeviceState *get_boot_device (uint32_t position) {uint32_t counter =0 ;
Quoted 134 lines · lijun
Quoted 117 lines · Marcel Apfelbaum
Quoted 101 lines · Jun Li
Add
remove_boot_device_path()function to remove bootindex when hot-unplug a device. This patch fixed virtio-blk/virtio-net/scsi-disk/scsi-generic device. So it has fixed bug1086603, ref:
https://bugzilla.redhat.com/show_bug.cgi?id=1086603Make some changes based on Andreas's good suggestion.
Signed-off-by Jun Li <[email protected]>--- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 1 + hw/scsi/scsi-disk.c | 6 ++++-- hw/scsi/scsi-generic.c | 3 +++ include/sysemu/sysemu.h | 2 ++ vl.c | 16 ++++++++++++++++ 6 files changed, 27 insertions(+), 2 deletions(-)hw/block/virtio-blk.c +1
-0@@ -752,6 +752,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)unregister_savevm (dev,"virtio-blk" , s);blockdev_mark_auto_del (s->bs);virtio_cleanup (vdev); +remove_boot_device_path (s->conf->bootindex, dev,"/disk@0,0" ); }static Property virtio_blk_properties[] = {hw/net/virtio-net.c +1
-0@@ -1633,6 +1633,7 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)g_free (n->vqs);qemu_del_nic (n->nic);virtio_cleanup (vdev); +remove_boot_device_path (n->nic_conf.bootindex, dev,"/ethernet-phy@0" ); }static void virtio_net_instance_init (Object *obj)hw/scsi/scsi-disk.c +4
-2@@ -2150,12 +2150,14 @@ static void scsi_disk_reset(DeviceState *dev) s->tray_open =0 ; } -static void scsi_destroy (SCSIDevice *dev) +static void scsi_destroy (SCSIDevice *sdev) { -SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, dev); +SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, sdev); +DeviceState *dev =DEVICE (sdev);scsi_device_purge_requests (&s->qdev,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->qdev.conf.bs); +remove_boot_device_path (s->qdev.conf.bootindex, dev,NULL ); }static void scsi_disk_resize_cb (void *opaque)hw/scsi/scsi-generic.c +3
-0@@ -388,8 +388,11 @@ static void scsi_generic_reset(DeviceState *dev)static void scsi_destroy (SCSIDevice *s) { +DeviceState *dev =DEVICE (s); +scsi_device_purge_requests (s,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->conf.bs); +remove_boot_device_path (s->conf.bootindex, dev,NULL ); }static int scsi_generic_initfn (SCSIDevice *s)include/sysemu/sysemu.h +2
-0@@ -193,6 +193,8 @@ void rtc_change_mon_event(struct tm *tm);void add_boot_device_path (int32_t bootindex,DeviceState *dev,const char *suffix); +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix);char *get_boot_devices_list (size_t *size,bool ignore_suffixes);DeviceState *get_boot_device (uint32_t position);vl.c +2
-0@@ -1184,6 +1184,22 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,QTAILQ_INSERT_TAIL (&fw_boot_order, node, link); } +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix)vl.c void add_boot_device_path(int32_t bootindex, DeviceState *dev, · line 1198
Quoted 10 lines
vl.c +10
-0+{ +FWBootEntry *node, *next_node; + +if (bootindex ==-1 ) { +return ; + } + + QTAILQ_FOREACH_SAFE(node, &fw_boot_order, link, next_node) +if (node->bootindex == bootindex) { +QTAILQ_REMOVE (&fw_boot_order, node, link);Hi Liu.
Sorry for the late response, but I was in vacation :) . Your patch looks OK, I once wrote another one on the same issue (it touched the same problem, but it was *completely* different).Quoted 7 lines
Here is the *real* problem:
fw_boot_orderlist is not queried again on guest reboot, so 'touching' the list has no effect. While your code is correct (as far as I can tell), it seems that his place is after the above problem is solved.No one is currently working on this, feel free
to take this challenge. I'll help however I can.Hi Marcel,
Sorry, so later response. I got a heavy sick these days. I have see these discussion emails between you and Paolo.
After guest reboot, seabios will got devices info from boards(this boards be generated by qemu command line). Just as Paolo's explanations, but I am not familiar with seabios. I will do some research about this. Thank you very much.
Quoted 2 lines
BTW, My first name is Jun, my last name is Li, my English name is woodpecker, you could call me jun or woodpecker. :)
Hi Jun,
I hope you are feeling better!
If you need further assistance, just let us know.
Thanks,
Marcel
Quoted 15 lines
Best Regards,
Jun LiQuoted 10 lines
Quoted 8 lines
vl.c +4
-0+return ; + } +} +DeviceState *get_boot_device (uint32_t position) {uint32_t counter =0 ;
Quoted 135 lines · Marcel Apfelbaum
Quoted 134 lines · lijun
Quoted 117 lines · Marcel Apfelbaum
Quoted 101 lines · Jun Li
Add
remove_boot_device_path()function to remove bootindex when hot-unplug a device. This patch fixed virtio-blk/virtio-net/scsi-disk/scsi-generic device. So it has fixed bug1086603, ref:
https://bugzilla.redhat.com/show_bug.cgi?id=1086603Make some changes based on Andreas's good suggestion.
Signed-off-by Jun Li <[email protected]>--- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 1 + hw/scsi/scsi-disk.c | 6 ++++-- hw/scsi/scsi-generic.c | 3 +++ include/sysemu/sysemu.h | 2 ++ vl.c | 16 ++++++++++++++++ 6 files changed, 27 insertions(+), 2 deletions(-)hw/block/virtio-blk.c +1
-0@@ -752,6 +752,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)unregister_savevm (dev,"virtio-blk" , s);blockdev_mark_auto_del (s->bs);virtio_cleanup (vdev); +remove_boot_device_path (s->conf->bootindex, dev,"/disk@0,0" ); }static Property virtio_blk_properties[] = {hw/net/virtio-net.c +1
-0@@ -1633,6 +1633,7 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)g_free (n->vqs);qemu_del_nic (n->nic);virtio_cleanup (vdev); +remove_boot_device_path (n->nic_conf.bootindex, dev,"/ethernet-phy@0" ); }static void virtio_net_instance_init (Object *obj)hw/scsi/scsi-disk.c +4
-2@@ -2150,12 +2150,14 @@ static void scsi_disk_reset(DeviceState *dev) s->tray_open =0 ; } -static void scsi_destroy (SCSIDevice *dev) +static void scsi_destroy (SCSIDevice *sdev) { -SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, dev); +SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, sdev); +DeviceState *dev =DEVICE (sdev);scsi_device_purge_requests (&s->qdev,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->qdev.conf.bs); +remove_boot_device_path (s->qdev.conf.bootindex, dev,NULL ); }static void scsi_disk_resize_cb (void *opaque)hw/scsi/scsi-generic.c +3
-0@@ -388,8 +388,11 @@ static void scsi_generic_reset(DeviceState *dev)static void scsi_destroy (SCSIDevice *s) { +DeviceState *dev =DEVICE (s); +scsi_device_purge_requests (s,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->conf.bs); +remove_boot_device_path (s->conf.bootindex, dev,NULL ); }static int scsi_generic_initfn (SCSIDevice *s)include/sysemu/sysemu.h +2
-0@@ -193,6 +193,8 @@ void rtc_change_mon_event(struct tm *tm);void add_boot_device_path (int32_t bootindex,DeviceState *dev,const char *suffix); +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix);char *get_boot_devices_list (size_t *size,bool ignore_suffixes);DeviceState *get_boot_device (uint32_t position);vl.c +2
-0@@ -1184,6 +1184,22 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,QTAILQ_INSERT_TAIL (&fw_boot_order, node, link); } +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix)vl.c void add_boot_device_path(int32_t bootindex, DeviceState *dev, · line 1198
Quoted 10 lines
vl.c +10
-0+{ +FWBootEntry *node, *next_node; + +if (bootindex ==-1 ) { +return ; + } + + QTAILQ_FOREACH_SAFE(node, &fw_boot_order, link, next_node) +if (node->bootindex == bootindex) { +QTAILQ_REMOVE (&fw_boot_order, node, link);Hi Liu.
Sorry for the late response, but I was in vacation :) . Your patch looks OK, I once wrote another one on the same issue (it touched the same problem, but it was *completely* different).Quoted 7 lines
Here is the *real* problem:
fw_boot_orderlist is not queried again on guest reboot, so 'touching' the list has no effect. While your code is correct (as far as I can tell), it seems that his place is after the above problem is solved.No one is currently working on this, feel free
to take this challenge. I'll help however I can.Hi Marcel,
Sorry, so later response. I got a heavy sick these days. I have see these discussion emails between you and Paolo.
After guest reboot, seabios will got devices info from boards(this boards be generated by qemu command line). Just as Paolo's explanations, but I am not familiar with seabios. I will do some research about this. Thank you very much.
Quoted 5 lines
Quoted 2 lines
BTW, My first name is Jun, my last name is Li, my English name is woodpecker, you could call me jun or woodpecker. :)
Hi Jun,
I hope you are feeling better!
If you need further assistance, just let us know.
Hi Marcel,
I just do a glancing debug, find that, when reboot guest, It will call function qemu_system_reset. So I want to add reset "fw_cfg" in function qemu_system_reset. Maybe this can fix your issue. But I have not try due to the limited time. This is just an ideal. As I am a sparetime "developer", so I can just fix this issue at weekend. So sorry.
Thanks,
Jun Li
Quoted 140 lines · Jun Li
Quoted 125 lines · Marcel Apfelbaum
Quoted 124 lines · lijun
Quoted 107 lines · Marcel Apfelbaum
Quoted 91 lines · Jun Li
Add
remove_boot_device_path()function to remove bootindex when hot-unplug a device. This patch fixed virtio-blk/virtio-net/scsi-disk/scsi-generic device. So it has fixed bug1086603, ref:
https://bugzilla.redhat.com/show_bug.cgi?id=1086603Make some changes based on Andreas's good suggestion.
Signed-off-by Jun Li <[email protected]>--- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 1 + hw/scsi/scsi-disk.c | 6 ++++-- hw/scsi/scsi-generic.c | 3 +++ include/sysemu/sysemu.h | 2 ++ vl.c | 16 ++++++++++++++++ 6 files changed, 27 insertions(+), 2 deletions(-)hw/block/virtio-blk.c +1
-0@@ -752,6 +752,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)unregister_savevm (dev,"virtio-blk" , s);blockdev_mark_auto_del (s->bs);virtio_cleanup (vdev); +remove_boot_device_path (s->conf->bootindex, dev,"/disk@0,0" ); }static Property virtio_blk_properties[] = {hw/net/virtio-net.c +1
-0@@ -1633,6 +1633,7 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)g_free (n->vqs);qemu_del_nic (n->nic);virtio_cleanup (vdev); +remove_boot_device_path (n->nic_conf.bootindex, dev,"/ethernet-phy@0" ); }static void virtio_net_instance_init (Object *obj)hw/scsi/scsi-disk.c +4
-2@@ -2150,12 +2150,14 @@ static void scsi_disk_reset(DeviceState *dev) s->tray_open =0 ; } -static void scsi_destroy (SCSIDevice *dev) +static void scsi_destroy (SCSIDevice *sdev) { -SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, dev); +SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, sdev); +DeviceState *dev =DEVICE (sdev);scsi_device_purge_requests (&s->qdev,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->qdev.conf.bs); +remove_boot_device_path (s->qdev.conf.bootindex, dev,NULL ); }static void scsi_disk_resize_cb (void *opaque)hw/scsi/scsi-generic.c +3
-0@@ -388,8 +388,11 @@ static void scsi_generic_reset(DeviceState *dev)static void scsi_destroy (SCSIDevice *s) { +DeviceState *dev =DEVICE (s); +scsi_device_purge_requests (s,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->conf.bs); +remove_boot_device_path (s->conf.bootindex, dev,NULL ); }static int scsi_generic_initfn (SCSIDevice *s)include/sysemu/sysemu.h +2
-0@@ -193,6 +193,8 @@ void rtc_change_mon_event(struct tm *tm);void add_boot_device_path (int32_t bootindex,DeviceState *dev,const char *suffix); +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix);char *get_boot_devices_list (size_t *size,bool ignore_suffixes);DeviceState *get_boot_device (uint32_t position);vl.c +2
-0@@ -1184,6 +1184,22 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,QTAILQ_INSERT_TAIL (&fw_boot_order, node, link); } +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix)vl.c void add_boot_device_path(int32_t bootindex, DeviceState *dev, · line 1197
Quoted 10 lines
vl.c +10
-0+{ +FWBootEntry *node, *next_node; + +if (bootindex ==-1 ) { +return ; + } + + QTAILQ_FOREACH_SAFE(node, &fw_boot_order, link, next_node) +if (node->bootindex == bootindex) { +QTAILQ_REMOVE (&fw_boot_order, node, link);Hi Liu.
Sorry for the late response, but I was in vacation :) . Your patch looks OK, I once wrote another one on the same issue (it touched the same problem, but it was *completely* different).Quoted 7 lines
Here is the *real* problem:
fw_boot_orderlist is not queried again on guest reboot, so 'touching' the list has no effect. While your code is correct (as far as I can tell), it seems that his place is after the above problem is solved.No one is currently working on this, feel free
to take this challenge. I'll help however I can.Hi Marcel,
Sorry, so later response. I got a heavy sick these days. I have see these discussion emails between you and Paolo.
After guest reboot, seabios will got devices info from boards(this boards be generated by qemu command line). Just as Paolo's explanations, but I am not familiar with seabios. I will do some research about this. Thank you very much.Quoted 5 lines
Quoted 2 lines
BTW, My first name is Jun, my last name is Li, my English name is woodpecker, you could call me jun or woodpecker. :)
Hi Jun,
I hope you are feeling better!
If you need further assistance, just let us know.Hi Marcel,
I just do a glancing debug, find that, when reboot guest, It will call functionqemu_system_reset. So I want to add reset "fw_cfg" in functionqemu_system_reset. Maybe this can fix your issue. But I have not try due to the limited time. This is just an ideal. As I am a sparetime "developer", so I can just fix this issue at weekend. So sorry.
Quoted 2 lines
Thanks,
Jun Li
Well FW CFG changing across reboots will create all kind of problems. So I think we should think about an alternative mechanism if we want to make it all dynamic, a static boot index number is a problematic api anyway, how do you prepare for ability to add more devices at arbitrary places? number everything 10,20,30, BASIC like?
For now your patch fixes a dangling pointer so I'll pick it up, thanks!
Signature · 1 line
MST
Quoted 96 lines · Jun Li
Add
remove_boot_device_path()function to remove bootindex when hot-unplug a device. This patch fixed virtio-blk/virtio-net/scsi-disk/scsi-generic device. So it has fixed bug1086603, ref:
https://bugzilla.redhat.com/show_bug.cgi?id=1086603Make some changes based on Andreas's good suggestion.
Signed-off-by Jun Li <[email protected]>--- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 1 + hw/scsi/scsi-disk.c | 6 ++++-- hw/scsi/scsi-generic.c | 3 +++ include/sysemu/sysemu.h | 2 ++ vl.c | 16 ++++++++++++++++ 6 files changed, 27 insertions(+), 2 deletions(-)hw/block/virtio-blk.c +1
-0@@ -752,6 +752,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)unregister_savevm (dev,"virtio-blk" , s);blockdev_mark_auto_del (s->bs);virtio_cleanup (vdev); +remove_boot_device_path (s->conf->bootindex, dev,"/disk@0,0" ); }static Property virtio_blk_properties[] = {hw/net/virtio-net.c +1
-0@@ -1633,6 +1633,7 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)g_free (n->vqs);qemu_del_nic (n->nic);virtio_cleanup (vdev); +remove_boot_device_path (n->nic_conf.bootindex, dev,"/ethernet-phy@0" ); }static void virtio_net_instance_init (Object *obj)hw/scsi/scsi-disk.c +4
-2@@ -2150,12 +2150,14 @@ static void scsi_disk_reset(DeviceState *dev) s->tray_open =0 ; } -static void scsi_destroy (SCSIDevice *dev) +static void scsi_destroy (SCSIDevice *sdev) { -SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, dev); +SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, sdev); +DeviceState *dev =DEVICE (sdev);scsi_device_purge_requests (&s->qdev,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->qdev.conf.bs); +remove_boot_device_path (s->qdev.conf.bootindex, dev,NULL ); }static void scsi_disk_resize_cb (void *opaque)hw/scsi/scsi-generic.c +3
-0@@ -388,8 +388,11 @@ static void scsi_generic_reset(DeviceState *dev)static void scsi_destroy (SCSIDevice *s) { +DeviceState *dev =DEVICE (s); +scsi_device_purge_requests (s,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->conf.bs); +remove_boot_device_path (s->conf.bootindex, dev,NULL ); }static int scsi_generic_initfn (SCSIDevice *s)include/sysemu/sysemu.h +2
-0@@ -193,6 +193,8 @@ void rtc_change_mon_event(struct tm *tm);void add_boot_device_path (int32_t bootindex,DeviceState *dev,const char *suffix); +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix);char *get_boot_devices_list (size_t *size,bool ignore_suffixes);DeviceState *get_boot_device (uint32_t position);vl.c +0
-0
vl.c void add_boot_device_path(int32_t bootindex, DeviceState *dev, · line 1188
Quoted 5 lines
vl.c +2
-0@@ -1184,6 +1184,22 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,QTAILQ_INSERT_TAIL (&fw_boot_order, node, link); } +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix)
Why do we need suffix here?
It seems unused.
Quoted 20 lines
vl.c +14
-0+{ +FWBootEntry *node, *next_node; + +if (bootindex ==-1 ) { +return ; + } + + QTAILQ_FOREACH_SAFE(node, &fw_boot_order, link, next_node) +if (node->bootindex == bootindex) { +QTAILQ_REMOVE (&fw_boot_order, node, link); +return ; + } +} +DeviceState *get_boot_device (uint32_t position) {uint32_t counter =0 ;Signature · 1 line
1.8.3.1
Quoted 100 lines · Michael S. Tsirkin
Quoted 99 lines · Jun Li
Add
remove_boot_device_path()function to remove bootindex when hot-unplug a device. This patch fixed virtio-blk/virtio-net/scsi-disk/scsi-generic device. So it has fixed bug1086603, ref:
https://bugzilla.redhat.com/show_bug.cgi?id=1086603Make some changes based on Andreas's good suggestion.
Signed-off-by Jun Li <[email protected]>--- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 1 + hw/scsi/scsi-disk.c | 6 ++++-- hw/scsi/scsi-generic.c | 3 +++ include/sysemu/sysemu.h | 2 ++ vl.c | 16 ++++++++++++++++ 6 files changed, 27 insertions(+), 2 deletions(-)hw/block/virtio-blk.c +1
-0@@ -752,6 +752,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)unregister_savevm (dev,"virtio-blk" , s);blockdev_mark_auto_del (s->bs);virtio_cleanup (vdev); +remove_boot_device_path (s->conf->bootindex, dev,"/disk@0,0" ); }static Property virtio_blk_properties[] = {hw/net/virtio-net.c +1
-0@@ -1633,6 +1633,7 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)g_free (n->vqs);qemu_del_nic (n->nic);virtio_cleanup (vdev); +remove_boot_device_path (n->nic_conf.bootindex, dev,"/ethernet-phy@0" ); }static void virtio_net_instance_init (Object *obj)hw/scsi/scsi-disk.c +4
-2@@ -2150,12 +2150,14 @@ static void scsi_disk_reset(DeviceState *dev) s->tray_open =0 ; } -static void scsi_destroy (SCSIDevice *dev) +static void scsi_destroy (SCSIDevice *sdev) { -SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, dev); +SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, sdev); +DeviceState *dev =DEVICE (sdev);scsi_device_purge_requests (&s->qdev,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->qdev.conf.bs); +remove_boot_device_path (s->qdev.conf.bootindex, dev,NULL ); }static void scsi_disk_resize_cb (void *opaque)hw/scsi/scsi-generic.c +3
-0@@ -388,8 +388,11 @@ static void scsi_generic_reset(DeviceState *dev)static void scsi_destroy (SCSIDevice *s) { +DeviceState *dev =DEVICE (s); +scsi_device_purge_requests (s,SENSE_CODE (NO_SENSE ));blockdev_mark_auto_del (s->conf.bs); +remove_boot_device_path (s->conf.bootindex, dev,NULL ); }static int scsi_generic_initfn (SCSIDevice *s)include/sysemu/sysemu.h +2
-0@@ -193,6 +193,8 @@ void rtc_change_mon_event(struct tm *tm);void add_boot_device_path (int32_t bootindex,DeviceState *dev,const char *suffix); +void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix);char *get_boot_devices_list (size_t *size,bool ignore_suffixes);DeviceState *get_boot_device (uint32_t position);vl.c +0
-0@@ -1184,6 +1184,22 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,QTAILQ_INSERT_TAIL (&fw_boot_order, node, link); }
Quoted 4 lines
vl.c void add_boot_device_path(int32_t bootindex, DeviceState *dev, · line 1188
Quoted 2 lines
vl.c +2
-0+void remove_boot_device_path (int32_t bootindex,DeviceState *dev, +const char *suffix)Why do we need suffix here?
It seems unused.
Hi Michael,
I just want to keep the same as function "add_boot_device_path". Such as:
void add_boot_device_path(int32_t bootindex, DeviceState *dev,
const char *suffix)
I also find another function has define mon, but not be used in this function. Such as:
---file vl.c---do_usb_del(Monitor *mon, const QDict *qdict)
{
const char *devname = qdict_get_str(qdict, "devname");
if (usb_device_del(devname) < 0) {
error_report("could not delete USB device '%s'", devname);
}
}Best Regards,
Jun Li
Quoted 20 lines
Quoted 20 lines
vl.c +14
-0+{ +FWBootEntry *node, *next_node; + +if (bootindex ==-1 ) { +return ; + } + + QTAILQ_FOREACH_SAFE(node, &fw_boot_order, link, next_node) +if (node->bootindex == bootindex) { +QTAILQ_REMOVE (&fw_boot_order, node, link); +return ; + } +} +DeviceState *get_boot_device (uint32_t position) {uint32_t counter =0 ;Signature · 1 line
1.8.3.1
Quoted 2 lines · Jun Li
Quoted 1 line · Michael S. Tsirkin
On Wed, Apr 16, 2014 at 10:20:57PM +0800, Jun Li wrote:
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
vl.c +0
-0
Quoted 8 lines
Quoted 8 lines
vl.c void add_boot_device_path(int32_t bootindex, DeviceState *dev, · line 1188
Quoted 6 lines
vl.c +1
-0@@ -1184,6 +1184,22 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,QTAILQ_INSERT_TAIL (&fw_boot_order, node, link); } +void remove_boot_device_path(int32_t bootindex, DeviceState *dev, + const char *suffix)Why do we need suffix here?
It seems unused.
dev is unused as well.
Quoted 5 lines
Hi Michael,
I just want to keep the same as function "
add_boot_device_path". Such as:
void add_boot_device_path(int32_t bootindex, DeviceState *dev,
const char *suffix)
Functions creating something commonly take different arguments than the function to destroy it.
Quoted 9 lines
I also find another function has define mon, but not be used in this function. Such as:
---file vl.c---do_usb_del(Monitor *mon, const QDict *qdict){ const char *devname = qdict_get_str(qdict, "devname"); if (usb_device_del(devname) < 0) { error_report("could not delete USB device '%s'", devname); } }
This one has a compelling reason: it's a mon_cmd_t mhandler.cmd callback.
Quoted 19 lines · Markus Armbruster
Quoted 2 lines · Jun Li
Quoted 1 line · Michael S. Tsirkin
On Wed, Apr 16, 2014 at 10:20:57PM +0800, Jun Li wrote:
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
vl.c +0
-0Quoted 8 lines
Quoted 8 lines
vl.c void add_boot_device_path(int32_t bootindex, DeviceState *dev, · line 1188
Quoted 6 lines
vl.c +1
-0@@ -1184,6 +1184,22 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,QTAILQ_INSERT_TAIL (&fw_boot_order, node, link); } +void remove_boot_device_path(int32_t bootindex, DeviceState *dev, + const char *suffix)Why do we need suffix here?
It seems unused.dev is unused as well.
Quoted 7 lines
Quoted 5 lines
Hi Michael,
I just want to keep the same as function "
add_boot_device_path". Such as:
void add_boot_device_path(int32_t bootindex, DeviceState *dev,
const char *suffix)Functions creating something commonly take different arguments than the function to destroy it.
ok, I will submit a update version for this patch.
Quoted 10 lines
Quoted 10 lines
I also find another function has define mon, but not be used in this function. Such as:
---file vl.c---do_usb_del(Monitor *mon, const QDict *qdict){ const char *devname = qdict_get_str(qdict, "devname"); if (usb_device_del(devname) < 0) { error_report("could not delete USB device '%s'", devname); } }
Quoted 2 lines
This one has a compelling reason: it's a
mon_cmd_tmhandler.cmd callback.
oh, thanks for your explanation.
Best Regards,
Jun Li