qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Igor Mitsyanko <i.mitsyanko@samsung.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	peter.maydell@linaro.org, quintela@redhat.com, michael@walle.cc,
	qemu-devel@nongnu.org, kyungmin.park@samsung.com,
	paul@codesourcery.com, Luiz Capitulino <lcapitulino@redhat.com>,
	afaerber@suse.de, d.solodkiy@samsung.com
Subject: Re: [Qemu-devel] [PATCH V2 10/10] hw/sd.c: introduce SD card "image" property and allow SD hot-insert
Date: Thu, 05 Apr 2012 19:02:23 +0200	[thread overview]
Message-ID: <4F7DD01F.9090801@redhat.com> (raw)
In-Reply-To: <1333640913-16028-11-git-send-email-i.mitsyanko@samsung.com>

Il 05/04/2012 17:48, Igor Mitsyanko ha scritto:
> New SD card "image" property can be used to:
> - change image file attached to virtual SD card
> - hot-insert new image file into newly initialized BlockDriverState (this was not
> possible before).
> 
> Example usage:
> ./qom-set /machine/milkymist/milkymist-memcard/card.image /home/me/mynewcard.img
> this will attach image file /home/me/mynewcard.img to virtual SD card connected to
> milkymist-memcard host controller device. If virtual card was already attached to
> some other image file, eject event is triggered before attaching new file.
> 
> Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
> ---
>  hw/sd.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 44 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/sd.c b/hw/sd.c
> index 8ffaa17..3e75405 100644
> --- a/hw/sd.c
> +++ b/hw/sd.c
> @@ -1816,6 +1816,48 @@ static void sd_set_spimode(Object *obj, Visitor *v, void *opaque,
>      }
>  }
>  
> +static void sd_set_image_path(Object *obj, Visitor *v, void *opaque,
> +                         const char *name, Error **errp)
> +{
> +    SDState *sd = SD_CARD(obj);
> +    char *new_image;
> +
> +    visit_type_str(v, &new_image, "file", errp);

Please use the name argument instead of "file".

> +
> +    if (error_is_set(errp)) {
> +        return;
> +    }
> +
> +    if (sd->bdrv) {
> +        qmp_change_blockdev(bdrv_get_device_name(sd->bdrv), new_image,
> +                false, NULL, errp);
> +    } else {
> +        DriveInfo *di;
> +        QemuOpts *opts = drive_add(IF_SD, sd->if_idx, new_image, "");

I think this should simply take a drive name and pass it to
bdrv_get_device_name.  The drive_add/drive_init should be done
separately with the drive_add monitor command, like

drive_add 0 file=foo.img,if=none,id=bar

With the upcoming support for static properties in objects that are not
devices, you can just add a drive property to the SD class.

There is a problem here however.  QOM commands are HMP only, and
drive_add is QMP only.  I think that blocking drive_add in QMP is
perfect being the enemy of good.  Alternatively, however, adding the QOM
property commands to HMP would also make sense.

Paolo

      reply	other threads:[~2012-04-05 17:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-05 15:48 [Qemu-devel] [PATCH V2 00/10] SD save/load support and SD qomification Igor Mitsyanko
2012-04-05 15:48 ` [Qemu-devel] [PATCH V2 01/10] hw/sd.c: convert wp_groups in SDState to bitfield Igor Mitsyanko
2012-04-05 15:48 ` [Qemu-devel] [PATCH V2 03/10] hw/sd.c: make sd_dataready() return bool Igor Mitsyanko
2012-04-05 15:48 ` [Qemu-devel] [PATCH V2 05/10] hw/sd.c: add SD card save/load support Igor Mitsyanko
2012-04-05 15:48 ` [Qemu-devel] [PATCH V2 06/10] hw/sd.c: convert to QOM object Igor Mitsyanko
2012-04-05 15:48 ` [Qemu-devel] [PATCH V2 07/10] SD card: introduce "if-idx" property for SD card objects Igor Mitsyanko
2012-04-05 15:48 ` [Qemu-devel] [PATCH V2 08/10] SD card: introduce "spi_mode" " Igor Mitsyanko
2012-04-05 15:48 ` [Qemu-devel] [PATCH V2 09/10] SD card: make SD card a child of host controller Igor Mitsyanko
2012-04-05 15:48 ` [Qemu-devel] [PATCH V2 10/10] hw/sd.c: introduce SD card "image" property and allow SD hot-insert Igor Mitsyanko
2012-04-05 17:02   ` Paolo Bonzini [this message]

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=4F7DD01F.9090801@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=afaerber@suse.de \
    --cc=d.solodkiy@samsung.com \
    --cc=i.mitsyanko@samsung.com \
    --cc=kwolf@redhat.com \
    --cc=kyungmin.park@samsung.com \
    --cc=lcapitulino@redhat.com \
    --cc=michael@walle.cc \
    --cc=paul@codesourcery.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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).