[libvirt] [PATCH v5] qemu: call drive_del in DetachPciDiskDevice
Daniel P. Berrange
berrange at redhat.com
Tue Nov 16 10:12:51 UTC 2010
On Fri, Nov 12, 2010 at 12:23:41PM -0600, Ryan Harper wrote:
> Currently libvirt doesn't confirm whether the guest has responded to the
> disk removal request. In some cases this can leave the guest with
> continued access to the device while the mgmt layer believes that it has
> been removed. With a recent qemu monitor command[1] we can
> deterministically revoke a guests access to the disk (on the QEMU side)
> to ensure no futher access is permitted.
>
> This patch adds support for the drive_del() command and introduces it
> in the disk removal paths. If the guest is running in a QEMU without this
> command we currently explicitly check for unknown command/CommandNotFound
> and log the issue.
>
> If QEMU supports the command we issue the drive_del command after we attempt
> to remove the device. The guest may respond and remove the block device
> before we get to attempt to call drive_del. In that case, we explicitly check
> for 'Device not found' from the monitor indicating that the target drive
> was auto-deleted upon guest responds to the device removal notification.
>
> 1. http://thread.gmane.org/gmane.comp.emulators.qemu/84745
>
> Signed-off-by: Ryan Harper <ryanh at us.ibm.com>
> ---
> Changes since v4:
> - removed PATH_MAX, use virAsprintf()
> - moved drivestr allocation before call to EnterMonitor
> Changes since v3:
> - Renamed DriveUnplug -> DriveDel, use drive_del monitor cmd.
> - Moved invocation to after DelDevice and guest notification.
> - Handle the case where drive is auto-deleted before we call
> DriveDel by catching and ignoring 'Device not found' error.
> - Simplified DriveDel invocation; no need to check return codes
> as the monitor implementations handle all failure case and logs
> or ignores as needed.
> Changes since v2:
> - use VIR_ERROR to report when unplug command not found
> Changes since v1:
> - return > 0 when command isn't present, < 0 on command failure
> - detect when drive_unplug command isn't present and log error
> instead of failing entire command
>
> src/qemu/qemu_driver.c | 28 +++++++++++++++++++++
> src/qemu/qemu_monitor.c | 19 ++++++++++++++
> src/qemu/qemu_monitor.h | 3 ++
> src/qemu/qemu_monitor_json.c | 38 +++++++++++++++++++++++++++++
> src/qemu/qemu_monitor_json.h | 3 ++
> src/qemu/qemu_monitor_text.c | 54 ++++++++++++++++++++++++++++++++++++++++++
> src/qemu/qemu_monitor_text.h | 3 ++
> 7 files changed, 148 insertions(+), 0 deletions(-)
ACK, once this drive_del hits the main QEMU git repos
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
More information about the libvir-list
mailing list