All of lore.kernel.org
 help / color / mirror / Atom feed
From: <arei.gonglei@huawei.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, weidong.huang@huawei.com,
	mst@redhat.com, aik@ozlabs.ru, armbru@redhat.com,
	kraxel@redhat.com, dmitry@daynix.com, akong@redhat.com,
	agraf@suse.de, Gonglei <arei.gonglei@huawei.com>,
	lersek@redhat.com, marcel.a@redhat.com, somlo@cmu.edu,
	luonengjun@huawei.com, peter.huangpeng@huawei.com,
	alex.williamson@redhat.com, stefanha@redhat.com,
	pbonzini@redhat.com, lcapitulino@redhat.com, rth@twiddle.net,
	kwolf@redhat.com, peter.crosthwaite@xilinx.com,
	Chenliang <chenliang88@huawei.com>,
	imammedo@redhat.com, afaerber@suse.de
Subject: [Qemu-devel] [RFC PATCH 1/5] bootindex: add *_boot_device_path function
Date: Mon, 7 Jul 2014 17:10:57 +0800	[thread overview]
Message-ID: <1404724261-9412-2-git-send-email-arei.gonglei@huawei.com> (raw)
In-Reply-To: <1404724261-9412-1-git-send-email-arei.gonglei@huawei.com>

From: Chenliang <chenliang88@huawei.com>

Add del_boot_device_path and modify_boot_device_path. Device should
be removed from boot device list  by del_boot_device_path when device
hotplug. modify_boot_device_path is used to modify deviceboot order.

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

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 285c45b..38ef1cd 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -204,6 +204,10 @@ 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(int32_t bootindex, DeviceState *dev,
+                          const char *suffix);
+void modify_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);
diff --git a/vl.c b/vl.c
index a1686ef..6264e11 100644
--- a/vl.c
+++ b/vl.c
@@ -1247,6 +1247,61 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
     QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
 }
 
+static bool is_same_fw_dev_path(DeviceState *src, DeviceState *target)
+{
+    bool ret = false;
+    char *devpath_src = qdev_get_fw_dev_path(src);
+    char *devpath_target = qdev_get_fw_dev_path(target);
+
+    if (!strcmp(devpath_src, devpath_target)) {
+        ret = true;
+    }
+
+    g_free(devpath_src);
+    g_free(devpath_target);
+    return ret;
+}
+
+void del_boot_device_path(int32_t bootindex, DeviceState *dev,
+                          const char *suffix)
+{
+    FWBootEntry *i;
+
+    assert(dev != NULL);
+
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        if (is_same_fw_dev_path(i->dev, dev)) {
+            if (suffix && i->suffix && strcmp(i->suffix, suffix)) {
+                continue;
+            }
+            QTAILQ_REMOVE(&fw_boot_order, i, link);
+            g_free(i->suffix);
+            g_free(i);
+            break;
+        }
+    }
+
+    if (bootindex == -1) {
+        return;
+    }
+
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        if (i->bootindex == bootindex) {
+            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)
+{
+    del_boot_device_path(bootindex, dev, suffix);
+    add_boot_device_path(bootindex, dev, suffix);
+}
+
 DeviceState *get_boot_device(uint32_t position)
 {
     uint32_t counter = 0;
-- 
1.7.12.4

  reply	other threads:[~2014-07-07  9:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-07  9:10 [Qemu-devel] [RFC PATCH 0/5] modify boot order when vm is running arei.gonglei
2014-07-07  9:10 ` arei.gonglei [this message]
2014-07-08  8:33   ` [Qemu-devel] [RFC PATCH 1/5] bootindex: add *_boot_device_path function Amos Kong
2014-07-08 11:02     ` ChenLiang
2014-07-08 13:22       ` Gonglei (Arei)
2014-07-08 14:55         ` Amos Kong
2014-07-09  1:03           ` Gonglei (Arei)
2014-07-07  9:10 ` [Qemu-devel] [RFC PATCH 2/5] bootindex: reset bootindex when vm reset arei.gonglei
2014-07-07  9:10 ` [Qemu-devel] [RFC PATCH 3/5] bootindex: delete boot index when device is removed arei.gonglei
2014-07-07  9:11 ` [Qemu-devel] [RFC PATCH 4/5] bootindex: add qmp to set boot index when vm is running arei.gonglei
2014-07-07  9:11 ` [Qemu-devel] [RFC PATCH 5/5] bootindex: fix memory leak when set boot index arei.gonglei
2014-07-07  9:29 ` [Qemu-devel] [RFC PATCH 0/5] modify boot order when vm is running Michael S. Tsirkin
2014-07-07 10:03   ` Laszlo Ersek
2014-07-07 11:12     ` Gonglei (Arei)
2014-07-07 14:40       ` Laszlo Ersek
2014-07-08  0:54         ` Gonglei (Arei)
2014-07-07 11:08   ` Gonglei (Arei)
2014-07-07 13:07     ` Michael S. Tsirkin
2014-07-08  1:06       ` Gonglei (Arei)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1404724261-9412-2-git-send-email-arei.gonglei@huawei.com \
    --to=arei.gonglei@huawei.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=akong@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=chenliang88@huawei.com \
    --cc=dmitry@daynix.com \
    --cc=imammedo@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=lersek@redhat.com \
    --cc=luonengjun@huawei.com \
    --cc=marcel.a@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=somlo@cmu.edu \
    --cc=stefanha@redhat.com \
    --cc=weidong.huang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.