From: Dustin Kirkland <kirkland@canonical.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [STABLE PATCH] hotplug: fix scsi hotplug.
Date: Wed, 14 Oct 2009 12:30:24 -0500 [thread overview]
Message-ID: <d9c105ea0910141030g5583121ex80a980cd975d2be7@mail.gmail.com> (raw)
In-Reply-To: <1255527031-19008-1-git-send-email-kraxel@redhat.com>
On Wed, Oct 14, 2009 at 8:30 AM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> Well, partly just papering over the issues. But without proper scsi bus
> infrastructure we hardly can do better. Changes:
>
> * Avoid auto-attach by setting the bus number to -1.
> * Ignore the unit value calculated by drive_init().
> * Explicitly attach the devices to the adapter.
> * Add sanity checks. Don't allow attaching scsi drives to your
> network device.
> * Kill the bus+unit printing. The values are bogus, and we can't
> easily figure the correct ones. I doubt this ever worked correctly
> with multiple scsi adapters present in the system.
>
> Should come more close to the expected behavior now ...
>
> Oh, and pc-bios/bios.bin needs a update too, otherwise pci hotplug
> doesn't work at all.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/pci-hotplug.c | 24 +++++++++++++++++++-----
> pc-bios/bios.bin | Bin 131072 -> 131072 bytes
> 2 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
> index d0f2911..8bedea2 100644
> --- a/hw/pci-hotplug.c
> +++ b/hw/pci-hotplug.c
> @@ -52,9 +52,10 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
> {
> int dom, pci_bus;
> unsigned slot;
> - int drive_idx, type, bus;
> + int drive_idx, type;
> int success = 0;
> PCIDevice *dev;
> + char buf[128];
>
> if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
> return;
> @@ -74,11 +75,19 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
> return;
> }
> type = drives_table[drive_idx].type;
> - bus = drive_get_max_bus (type);
>
> switch (type) {
> case IF_SCSI:
> + if (!dev->qdev.info || strcmp(dev->qdev.info->name, "lsi53c895a") != 0) {
> + monitor_printf(mon, "Device is not a scsi adapter\n");
> + break;
> + }
> success = 1;
> + drives_table[drive_idx].bus = -1;
> + drives_table[drive_idx].unit = -1;
> + if (get_param_value(buf, sizeof(buf), "unit", opts)) {
> + drives_table[drive_idx].unit = atoi(buf);
> + }
> lsi_scsi_attach(&dev->qdev, drives_table[drive_idx].bdrv,
> drives_table[drive_idx].unit);
> break;
> @@ -87,9 +96,7 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
> }
>
> if (success)
> - monitor_printf(mon, "OK bus %d, unit %d\n",
> - drives_table[drive_idx].bus,
> - drives_table[drive_idx].unit);
> + monitor_printf(mon, "OK\n");
> return;
> }
>
> @@ -130,7 +137,14 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
>
> switch (type) {
> case IF_SCSI:
> + drives_table[drive_idx].bus = -1;
> + drives_table[drive_idx].unit = -1;
> + if (get_param_value(buf, sizeof(buf), "unit", opts)) {
> + drives_table[drive_idx].unit = atoi(buf);
> + }
> dev = pci_create("lsi53c895a", devaddr);
> + lsi_scsi_attach(&dev->qdev, drives_table[drive_idx].bdrv,
> + drives_table[drive_idx].unit);
> break;
> case IF_VIRTIO:
> dev = pci_create("virtio-blk-pci", devaddr);
Thanks, Gerd.
I applied this patch against qemu-kvm-0.11.0 stable, built, and tested
it. I can verify that it fixes the scsi hot-add issues I was seeing.
I am now able to add/remove/add/remove/add/remove a scsi disk to a
running instance without segfaulting qemu.
Note that on remove, I do get a stack track in the guest's kernel
(2.6.31), though the remove does succeed, and the disk disappears.
Also note that I did not replace the bios.bin, as it appears to me
that the qemu-kvm-0.11 bios.bin is working properly.
Tested-by: Dustin Kirkland <kirkland@canonical.com>
next prev parent reply other threads:[~2009-10-14 17:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-14 13:30 [Qemu-devel] [STABLE PATCH] hotplug: fix scsi hotplug Gerd Hoffmann
2009-10-14 14:49 ` Anthony Liguori
2009-10-14 15:44 ` Gerd Hoffmann
2009-10-14 15:43 ` Dustin Kirkland
2009-10-14 15:45 ` Gerd Hoffmann
2009-10-14 17:30 ` Dustin Kirkland [this message]
2009-10-15 7:42 ` Gerd Hoffmann
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=d9c105ea0910141030g5583121ex80a980cd975d2be7@mail.gmail.com \
--to=kirkland@canonical.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
/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).