diff mbox

[v3,2/7] bootindex: add del_boot_device_path function

Message ID 1406349933-17536-3-git-send-email-arei.gonglei@huawei.com
State New
Headers show

Commit Message

Gonglei (Arei) July 26, 2014, 4:45 a.m. UTC
From: Gonglei <arei.gonglei@huawei.com>

Introduce a del_boot_device_path() cleanup fw_cfg content
when hot-unplugging devcie refer to bootindex.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Chenliang <chenliang88@huawei.com>
---
 include/sysemu/sysemu.h |  1 +
 vl.c                    | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

Comments

Eric Blake July 31, 2014, 2:21 a.m. UTC | #1
On 07/25/2014 10:45 PM, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> Introduce a del_boot_device_path() cleanup fw_cfg content
> when hot-unplugging devcie refer to bootindex.

s/devcie/device/

sounds odd; maybe:

Introduce del_boot_device_path() to clean up fw_cfg content when
hot-unplugging a device that refers to a bootindex.

> +
> +    QTAILQ_FOREACH(i, &fw_boot_order, link) {
> +        if (i->dev->id && dev->id && !strcmp(i->dev->id, dev->id)) {
> +            /* remove all entries of the assigend dev */

s/assigend/assigned/
Gonglei (Arei) July 31, 2014, 2:24 a.m. UTC | #2
Hi,

> > Introduce a del_boot_device_path() cleanup fw_cfg content

> > when hot-unplugging devcie refer to bootindex.

> 

> s/devcie/device/

> 

> sounds odd; maybe:

> 

> Introduce del_boot_device_path() to clean up fw_cfg content when

> hot-unplugging a device that refers to a bootindex.

> 

OK. Thanks, Eric.

> > +

> > +    QTAILQ_FOREACH(i, &fw_boot_order, link) {

> > +        if (i->dev->id && dev->id && !strcmp(i->dev->id, dev->id)) {

> > +            /* remove all entries of the assigend dev */

> 

> s/assigend/assigned/

> 

OK.

> 

> --

> Eric Blake   eblake redhat com    +1-919-301-3266

> Libvirt virtualization library http://libvirt.org


Best regards,
-Gonglei
Eduardo Habkost Aug. 1, 2014, 2:06 p.m. UTC | #3
On Sat, Jul 26, 2014 at 12:45:28PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> Introduce a del_boot_device_path() cleanup fw_cfg content
> when hot-unplugging devcie refer to bootindex.
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> Signed-off-by: Chenliang <chenliang88@huawei.com>
> ---
>  include/sysemu/sysemu.h |  1 +
>  vl.c                    | 17 +++++++++++++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index e1b0659..7a79ff4 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -209,6 +209,7 @@ void usb_info(Monitor *mon, const QDict *qdict);
>  
>  void add_boot_device_path(int32_t bootindex, DeviceState *dev,
>                            const char *suffix);
> +void del_boot_device_path(DeviceState *dev);
>  void modify_boot_device_path(int32_t bootindex, DeviceState *dev,
>                               const char *suffix);
>  char *get_boot_devices_list(size_t *size, bool ignore_suffixes);
> diff --git a/vl.c b/vl.c
> index 3e42eaa..0cdadb4 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1248,6 +1248,23 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
>      QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
>  }
>  
> +void del_boot_device_path(DeviceState *dev)
> +{
> +    FWBootEntry *i;
> +
> +    assert(dev != NULL);
> +
> +    QTAILQ_FOREACH(i, &fw_boot_order, link) {
> +        if (i->dev->id && dev->id && !strcmp(i->dev->id, dev->id)) {

What if the device doesn't have any ID set? I don't see anything on
add_boot_device_path() ensuring that dev->id is always set.

Why you don't just check if i->dev == dev?


> +            /* remove all entries of the assigend dev */
> +            QTAILQ_REMOVE(&fw_boot_order, i, link);
> +            g_free(i->suffix);
> +            g_free(i);
> +            break;
> +        }
> +    }
> +}
> +
>  void modify_boot_device_path(int32_t bootindex, DeviceState *dev,
>                            const char *suffix)
>  {
> -- 
> 1.7.12.4
> 
> 
>
diff mbox

Patch

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index e1b0659..7a79ff4 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -209,6 +209,7 @@  void usb_info(Monitor *mon, const QDict *qdict);
 
 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix);
+void del_boot_device_path(DeviceState *dev);
 void modify_boot_device_path(int32_t bootindex, DeviceState *dev,
                              const char *suffix);
 char *get_boot_devices_list(size_t *size, bool ignore_suffixes);
diff --git a/vl.c b/vl.c
index 3e42eaa..0cdadb4 100644
--- a/vl.c
+++ b/vl.c
@@ -1248,6 +1248,23 @@  void add_boot_device_path(int32_t bootindex, DeviceState *dev,
     QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
 }
 
+void del_boot_device_path(DeviceState *dev)
+{
+    FWBootEntry *i;
+
+    assert(dev != NULL);
+
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        if (i->dev->id && dev->id && !strcmp(i->dev->id, dev->id)) {
+            /* remove all entries of the assigend dev */
+            QTAILQ_REMOVE(&fw_boot_order, i, link);
+            g_free(i->suffix);
+            g_free(i);
+            break;
+        }
+    }
+}
+
 void modify_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix)
 {