From: Jun Li <junmuzi@gmail.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com,
mst@redhat.com, marcel.a@redhat.com, juli@redhat.com,
aliguori@amazon.com, pbonzini@redhat.com,
Jun Li <junmuzi@gmail.com>,
afaerber@suse.de
Subject: [Qemu-devel] [PATCH v3] Add remove_boot_device_path() function for hot-unplug device
Date: Mon, 19 May 2014 23:03:28 +0800 [thread overview]
Message-ID: <1400511808-16929-1-git-send-email-junmuzi@gmail.com> (raw)
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.
Signed-off-by: Jun Li <junmuzi@gmail.com>
---
This patch also fixed bug1086603, ref:
https://bugzilla.redhat.com/show_bug.cgi?id=1086603
This version of patch delete dev and suffix parameter from function remove_boot_device_path().
---
hw/block/virtio-blk.c | 1 +
hw/net/virtio-net.c | 1 +
hw/scsi/scsi-disk.c | 1 +
hw/scsi/scsi-generic.c | 1 +
include/sysemu/sysemu.h | 1 +
vl.c | 15 +++++++++++++++
6 files changed, 20 insertions(+)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 8a568e5..497eb40 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -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);
}
static Property virtio_blk_properties[] = {
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 940a7cf..6afb1ca 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1645,6 +1645,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);
}
static void virtio_net_instance_init(Object *obj)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 4bcef55..d33df2e 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2156,6 +2156,7 @@ static void scsi_destroy(SCSIDevice *dev)
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);
}
static void scsi_disk_resize_cb(void *opaque)
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 3733d2c..d387f3e 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -390,6 +390,7 @@ static void scsi_destroy(SCSIDevice *s)
{
scsi_device_purge_requests(s, SENSE_CODE(NO_SENSE));
blockdev_mark_auto_del(s->conf.bs);
+ remove_boot_device_path(s->conf.bootindex);
}
static int scsi_generic_initfn(SCSIDevice *s)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index ba5c7f8..2510e3b 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -193,6 +193,7 @@ 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);
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 709d8cd..f31d008 100644
--- a/vl.c
+++ b/vl.c
@@ -1189,6 +1189,21 @@ 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)
+{
+ 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;
--
1.9.0
next reply other threads:[~2014-05-19 15:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 15:03 Jun Li [this message]
2014-05-19 15:31 ` [Qemu-devel] [PATCH v3] Add remove_boot_device_path() function for hot-unplug device Andreas Färber
2014-05-19 15:57 ` Michael S. Tsirkin
2014-05-21 8:13 ` Andreas Färber
2014-05-22 14:58 ` Jun Li
2014-05-21 7:50 ` Jun Li
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=1400511808-16929-1-git-send-email-junmuzi@gmail.com \
--to=junmuzi@gmail.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=famz@redhat.com \
--cc=juli@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcel.a@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).