qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Xie Changlong <xiechanglong.d@gmail.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Fam Zheng <famz@redhat.com>, Max Reitz <mreitz@redhat.com>,
	armbru@redhat.com
Subject: Re: [Qemu-devel] [Question] How can we confirm hot-plug disk succesfully?
Date: Mon, 19 Jun 2017 12:49:15 +0200	[thread overview]
Message-ID: <20170619104915.GC6113@noname.redhat.com> (raw)
In-Reply-To: <6324ce25-8fa8-9204-d15b-32f20fb71e4b@gmail.com>

Am 19.06.2017 um 12:27 hat Xie Changlong geschrieben:
> 在 6/19/2017 3:27 PM, Kevin Wolf 写道:
> >Am 18.06.2017 um 09:21 hat Xie Changlong geschrieben:
> >>In device hot-remove scenario, if we don't probe acpiphp module on
> >>the guest, 'device_del' will never emit DEVICE_DELETED event(because
> >>guest will not write to __EJ0) . So we can confirm that hot-remove
> >>failed. But IIUC, there is no event such as DEVICE_ADDED, so
> >>1) How can we confirm hotplug('device_add') successfully?
> >>2) It seems when hot-plug disk, we don't care acpiphp module status
> >>on the guest, am I right?
> >>3) Why there is no DEVICE_ADDED like event?
> >
> >device_add doesn't need guest cooperation, so it is immediately
> >completed when the QMP command returns success.
> >
> 
> That's what i though too. But I have a question, if we don't proble
> acpiphp on the guest, and execute below commands:
> 
> Hot plug:
> (qemu) drive_add 0
> file=/resource/changlox/test.raw,id=drive-virtio-disk1,if=none
> (qemu) device_add virtio-blk-pci,drive=drive-virtio-disk1,id=virtio-disk1
> 
> Hot remove:
> (qemu) device_del virtio-disk1
> (qemu) drive_del drive-virtio-disk1
> (qemu) qom-list /machine/peripheral
> type (string)
> virtio-disk1 (child<virtio-blk-pci>)
> (qemu) info block
> foo (#block122): suse1.qcow2 (qcow2)
>     Cache mode:       writeback, direct
>     Backing file:     suse.qcow2.orgin (chain depth: 1)
> 
> ide1-cd0: [not inserted]
>     Removable device: not locked, tray closed
> 
> floppy0: [not inserted]
>     Removable device: not locked, tray closed
> 
> sd0: [not inserted]
>     Removable device: not locked, tray closed
> (qemu) drive_add 0
> file=/resource/changlox/test.raw,id=drive-virtio-disk1,if=none
> Duplicate ID 'drive-virtio-disk1' for drive
> 
> 'info block' shows nothing, but we can't add drive who's id
> is'drive-virtio-disk1' too.

Yes, the old BlockBackend is only fully freed when the guest actually
unplugs the device. Specifically, we would have to free the QemuOpts
in DriveInfo that keeps the ID reserved. Currently, it is only freed
when the BlockBackend is destroyed:

    blockdev_auto_del()
        blk_unref()
            blk_delete()
                drive_info_del()

We can't free the DriveInfo earlier because it's still needed while the
guest device is still alive.

I'm not sure, but it may be possible to free just the QemuOpts in
monitor_remove_blk(), so that the ID can immediately be reused.

Markus, would you know?

> There is a more serious situation, we
> could *never* destory device memory with 'device_del', it's memory
> leak to me if the guest os never support hot-plug and the user don't
> know this information.

The user sees that they never get a DEVICE_REMOVED event, so in some way
the do know about it.

Kevin

  reply	other threads:[~2017-06-19 10:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-18  7:21 [Qemu-devel] [Question] How can we confirm hot-plug disk succesfully? Xie Changlong
2017-06-19  4:09 ` Xie Changlong
2017-06-19  7:27 ` Kevin Wolf
2017-06-19 10:27   ` Xie Changlong
2017-06-19 10:49     ` Kevin Wolf [this message]
2017-06-22  1:12       ` Xie Changlong
2017-06-22 13:56       ` Markus Armbruster

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=20170619104915.GC6113@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=xiechanglong.d@gmail.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).