qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, kevin@koconnor.net, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH] sdhci: Make device "sdhci-pci" unavailable with -device again
Date: Fri,  4 Dec 2015 15:07:47 +0100	[thread overview]
Message-ID: <1449238067-29794-1-git-send-email-armbru@redhat.com> (raw)

We made it unavailable in commit 1910913 because its use of
drive_get_next() instead of a property.  Commit 5ec911c replaced
drive_get_next() and made the device available, but the property isn't
quite right, and the code dangerously ignores blk_attach_dev()
failure.  Disable it again before the property becomes ABI, and mark
the dangerous spot FIXME.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/sd/sd.c    | 1 +
 hw/sd/sdhci.c | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index ce4d44b..d0be5ea 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -494,6 +494,7 @@ SDState *sd_init(BlockBackend *blk, bool is_spi)
     if (sd->blk) {
         /* Attach dev if not already attached.  (This call ignores an
          * error return code if sd->blk is already attached.) */
+        /* FIXME ignoring blk_attach_dev() failure is wrong and dangerous */
         blk_attach_dev(sd->blk, sd);
         blk_set_dev_ops(sd->blk, &sd_block_ops, sd);
     }
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index d70d1a6..0a338ed 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1261,6 +1261,12 @@ static void sdhci_pci_class_init(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
     dc->vmsd = &sdhci_vmstate;
     dc->props = sdhci_pci_properties;
+    /*
+     * Reason: realize() method uses sd_init(), which ignores
+     * blk_attach_dev() failure (potentially dangerous), and the block
+     * properties really belong to the card, not the controller.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo sdhci_pci_info = {
-- 
2.4.3

             reply	other threads:[~2015-12-04 14:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-04 14:07 Markus Armbruster [this message]
2015-12-04 14:33 ` [Qemu-devel] [PATCH] sdhci: Make device "sdhci-pci" unavailable with -device again Paolo Bonzini
2015-12-04 14:59   ` Markus Armbruster
2015-12-04 15:35     ` Paolo Bonzini

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=1449238067-29794-1-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=kevin@koconnor.net \
    --cc=peter.maydell@linaro.org \
    --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).