Re: [libvirt] [PATCH 0/2] Introduce two new virsh commands

2011-12-19 Thread Dave Allan
On Mon, Dec 19, 2011 at 12:41:08PM +0800, Osier Yang wrote:
 On 2011年06月30日 00:26, Eric Blake wrote:
 On 06/29/2011 06:19 AM, Osier Yang wrote:
 These two patches is to introduce two new virsh commands, one is
 eject-media, which is to eject media from CD or floppy drive, the other
 is insert-media, which is to insert media into CD or floppy drive.
 
 There are commands existed can be used to eject/insert media, such as
 update-device, but it's not quite easy to use. That's the original
 intention of these patches.
 
 Both of the two commands only allow to operate on CDROM or floppy disk.
 
 [PATCH 1/2] virsh: Introduce two new commands to insert or eject media
 [PATCH 2/2] doc: Add docs for two new introduced commands
 
 I think that we will eventually need even more; therefore, I'm thinking
 a more generic 'change-disk' command would be better than two specific
 'eject-media' and 'insert-media' commands.  Recent qemu added [1]:
 
   o blockdev-tray-open: opens the drive tray. Also Supports removing the
 inserted
 media. The BLOCK_TRAY_OPEN event is emitted if this command succeeds.
   o blockdev-tray-close: closes a drive tray. The BLOCK_TRAY_CLOSE event is
 emitted.
   o blockdev-media-insert: Inserts a media in the tray. The tray must empty
 and already opened. No event is emitted.
 
 along with updating to 'eject' and 'change' in terms of these more
 fundamental operations.
 
 [1] http://lists.nongnu.org/archive/html/qemu-devel/2011-06/msg00381.html
 
 There is no news for the these qemu patches since June. Should we
 still wait for that?
 
 We don't have to wait for the qemu patches if we seperate the media
 and tray management in virsh. i.e.
 
 insert-media  eject-media: for media management.
 tray-open  tray-close: for tray management (in future)
 
 OR
 
 change-media: for media management
 change-tray: for tray management
 
 Before the qemu introduce news monitor commands for media management,
 we can use current updateDeviceFlags API (which uses qemu's change),
 after the qemu commands for media management is introduced, we can
 add a simple switch to honor them. (Of course, we need to introduce
 new events support if qemu supports to emit events, but that's a
 separate work from virsh's point of view).
 
 On the other hand, from a user's point of view, separating management
 of media and tray could be more clear. However, having all the
 management scenarios for both tray and media in one command could be
 a bit confused.
 
 Thoughts?

I think there's a use for a syntactic sugar command for changing the
media which can be done today with update device.  That command
shouldn't depend on the additionally useful command for
opening/closing the tray.

Dave


 Regards,
 Osier
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 0/2] Introduce two new virsh commands

2011-12-18 Thread Osier Yang

On 2011年06月30日 00:26, Eric Blake wrote:

On 06/29/2011 06:19 AM, Osier Yang wrote:

These two patches is to introduce two new virsh commands, one is
eject-media, which is to eject media from CD or floppy drive, the other
is insert-media, which is to insert media into CD or floppy drive.

There are commands existed can be used to eject/insert media, such as
update-device, but it's not quite easy to use. That's the original
intention of these patches.

Both of the two commands only allow to operate on CDROM or floppy disk.

[PATCH 1/2] virsh: Introduce two new commands to insert or eject media
[PATCH 2/2] doc: Add docs for two new introduced commands


I think that we will eventually need even more; therefore, I'm thinking
a more generic 'change-disk' command would be better than two specific
'eject-media' and 'insert-media' commands.  Recent qemu added [1]:

  o blockdev-tray-open: opens the drive tray. Also Supports removing the
inserted
media. The BLOCK_TRAY_OPEN event is emitted if this command succeeds.
  o blockdev-tray-close: closes a drive tray. The BLOCK_TRAY_CLOSE event is
emitted.
  o blockdev-media-insert: Inserts a media in the tray. The tray must empty
and already opened. No event is emitted.

along with updating to 'eject' and 'change' in terms of these more
fundamental operations.

[1] http://lists.nongnu.org/archive/html/qemu-devel/2011-06/msg00381.html


There is no news for the these qemu patches since June. Should we
still wait for that?

We don't have to wait for the qemu patches if we seperate the media
and tray management in virsh. i.e.

insert-media  eject-media: for media management.
tray-open  tray-close: for tray management (in future)

OR

change-media: for media management
change-tray: for tray management

Before the qemu introduce news monitor commands for media management,
we can use current updateDeviceFlags API (which uses qemu's change),
after the qemu commands for media management is introduced, we can
add a simple switch to honor them. (Of course, we need to introduce
new events support if qemu supports to emit events, but that's a
separate work from virsh's point of view).

On the other hand, from a user's point of view, separating management
of media and tray could be more clear. However, having all the
management scenarios for both tray and media in one command could be
a bit confused.

Thoughts?

Regards,
Osier

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 0/2] Introduce two new virsh commands

2011-06-30 Thread Osier Yang

于 2011年06月30日 00:26, Eric Blake 写道:

On 06/29/2011 06:19 AM, Osier Yang wrote:

These two patches is to introduce two new virsh commands, one is
eject-media, which is to eject media from CD or floppy drive, the other
is insert-media, which is to insert media into CD or floppy drive.

There are commands existed can be used to eject/insert media, such as
update-device, but it's not quite easy to use. That's the original
intention of these patches.

Both of the two commands only allow to operate on CDROM or floppy disk.

[PATCH 1/2] virsh: Introduce two new commands to insert or eject media
[PATCH 2/2] doc: Add docs for two new introduced commands


I think that we will eventually need even more; therefore, I'm thinking
a more generic 'change-disk' command would be better than two specific
'eject-media' and 'insert-media' commands.  Recent qemu added [1]:

  o blockdev-tray-open: opens the drive tray. Also Supports removing the
inserted
media. The BLOCK_TRAY_OPEN event is emitted if this command succeeds.
  o blockdev-tray-close: closes a drive tray. The BLOCK_TRAY_CLOSE event is
emitted.
  o blockdev-media-insert: Inserts a media in the tray. The tray must empty
and already opened. No event is emitted.

along with updating to 'eject' and 'change' in terms of these more
fundamental operations.

[1] http://lists.nongnu.org/archive/html/qemu-devel/2011-06/msg00381.html


These patches are still not pushed in qemu upstream, but good to known
it, and agree with we need more if those patches are got pushed, so
wait for some while.



That is, it should be possible to have libvirt issue a command to tell
the guest's virtual cd tray to open, a command to tell the tray to
close, and a command to tell qemu to change which disk is in the tray
but leaving the tray open, and expose all of these through virsh.

Meanwhile, it should also be possible to register for events to be told
when the guest has initiated a tray open or tray close, although I'm not
quite as sure that events need to be exposed through virsh.

I think all of the new qemu monitor commands can be mapped into the
existing virDomainUpdateDeviceFlags by way of adding a new XML attribute
to thedevice/disk/target  element for guest cdrom devices, as in:

disk  type='file' device='cdrom'
   driver name='qemu' type='raw'/
   source file='/path/to/my.iso'/
   target dev='hdc' bus=ide' tray='open'/
/disk

I don't think we need any new flags to virDomainUpdateDeviceFlags;
rather, the additional xml attribute tray='open|closed' (omitted element
implies closed) should be sufficient to correctly decide which monitor
command(s) are necessary to get the virtual cdrom into the requested new
state.

Hmm, does qemu have a way at the command line to start a guest with the
tray already open?  If not, that feels like a missing qemu feature.

But from the virsh aspect, it seems like a more generic change-disk is
better than specific eject-media and insert-media commands:

change-disk domain target {--current | [--live] [--config]} [--force]
[{--open | --close}] {--keep | [media]}

Change the state of the virtual cdrom disktarget  withindomain.
--current,--live,--config  behave as usual.
If--force, then force the change even if the disk was previously
mounted by the guest.
Either--open  or--close  may be specified to change the state of the
virtual tray; if neither is given, the tray will be put back to its
original state (although if it was already closed, the process involves
temporarily opening the tray).
If--keep  is specified, then--open  or--close  only affects tray
state without changing media.  Otherwise, ifmedia  is specified, the
contents of the tray are changed to the new media, and ifmedia  is
omitted, then the tray is emptied.

Examples:

change-disk dom hdc --live /path/to/my.iso
=  checks for existingdisktarget dev='hdc'//disk  and tray state.
  If tray state is closed, this creates new xml that changes thesource
file='...'/, and calls virDomainUpdateDeviceFlags with the new XML,
which in turn attempts the 'change' monitor command which tries to open
the tray, swap the media, then close the tray; this will fail if the
guest has mounted the previous media and thus locked the tray.  If tray
state is open, then this maps to the 'blockdev-media-insert' monitor
command that changes the media but leaves the tray open.

change-disk dom hdc --live --force /path/to/my.iso
=  likewise, but with the force flag passed to
virDomainUpdateDeviceFlags, and thus to the 'change' monitor command, so
it should succeed

change-disk dom hdc
=  changes the xmlsource  to be empty, effectively removing the media
from the disk

change-disk dom hdc --open --keep
=  changes the xml to request the new tray=open attribute, but leaves
source  alone, so that the guest could initiate a tray-close action and
see the same .iso that was previously in the disk

change-disk dom hdc --close /path/to/my.iso
=  ensure that the new tray state is closed and contains the new iso,
even if the 

[libvirt] [PATCH 0/2] Introduce two new virsh commands

2011-06-29 Thread Osier Yang
These two patches is to introduce two new virsh commands, one is
eject-media, which is to eject media from CD or floppy drive, the other
is insert-media, which is to insert media into CD or floppy drive.

There are commands existed can be used to eject/insert media, such as
update-device, but it's not quite easy to use. That's the original
intention of these patches.

Both of the two commands only allow to operate on CDROM or floppy disk.

[PATCH 1/2] virsh: Introduce two new commands to insert or eject media
[PATCH 2/2] doc: Add docs for two new introduced commands

Regards
Osier

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 0/2] Introduce two new virsh commands

2011-06-29 Thread Eric Blake
On 06/29/2011 06:19 AM, Osier Yang wrote:
 These two patches is to introduce two new virsh commands, one is
 eject-media, which is to eject media from CD or floppy drive, the other
 is insert-media, which is to insert media into CD or floppy drive.
 
 There are commands existed can be used to eject/insert media, such as
 update-device, but it's not quite easy to use. That's the original
 intention of these patches.
 
 Both of the two commands only allow to operate on CDROM or floppy disk.
 
 [PATCH 1/2] virsh: Introduce two new commands to insert or eject media
 [PATCH 2/2] doc: Add docs for two new introduced commands

I think that we will eventually need even more; therefore, I'm thinking
a more generic 'change-disk' command would be better than two specific
'eject-media' and 'insert-media' commands.  Recent qemu added [1]:

 o blockdev-tray-open: opens the drive tray. Also Supports removing the
inserted
   media. The BLOCK_TRAY_OPEN event is emitted if this command succeeds.
 o blockdev-tray-close: closes a drive tray. The BLOCK_TRAY_CLOSE event is
   emitted.
 o blockdev-media-insert: Inserts a media in the tray. The tray must empty
   and already opened. No event is emitted.

along with updating to 'eject' and 'change' in terms of these more
fundamental operations.

[1] http://lists.nongnu.org/archive/html/qemu-devel/2011-06/msg00381.html

That is, it should be possible to have libvirt issue a command to tell
the guest's virtual cd tray to open, a command to tell the tray to
close, and a command to tell qemu to change which disk is in the tray
but leaving the tray open, and expose all of these through virsh.

Meanwhile, it should also be possible to register for events to be told
when the guest has initiated a tray open or tray close, although I'm not
quite as sure that events need to be exposed through virsh.

I think all of the new qemu monitor commands can be mapped into the
existing virDomainUpdateDeviceFlags by way of adding a new XML attribute
to the device/disk/target element for guest cdrom devices, as in:

disk type='file' device='cdrom'
  driver name='qemu' type='raw'/
  source file='/path/to/my.iso'/
  target dev='hdc' bus=ide' tray='open'/
/disk

I don't think we need any new flags to virDomainUpdateDeviceFlags;
rather, the additional xml attribute tray='open|closed' (omitted element
implies closed) should be sufficient to correctly decide which monitor
command(s) are necessary to get the virtual cdrom into the requested new
state.

Hmm, does qemu have a way at the command line to start a guest with the
tray already open?  If not, that feels like a missing qemu feature.

But from the virsh aspect, it seems like a more generic change-disk is
better than specific eject-media and insert-media commands:

change-disk domain target {--current | [--live] [--config]} [--force]
[{--open | --close}] {--keep | [media]}

Change the state of the virtual cdrom disk target within domain.
--current, --live, --config behave as usual.
If --force, then force the change even if the disk was previously
mounted by the guest.
Either --open or --close may be specified to change the state of the
virtual tray; if neither is given, the tray will be put back to its
original state (although if it was already closed, the process involves
temporarily opening the tray).
If --keep is specified, then --open or --close only affects tray
state without changing media.  Otherwise, if media is specified, the
contents of the tray are changed to the new media, and if media is
omitted, then the tray is emptied.

Examples:

change-disk dom hdc --live /path/to/my.iso
= checks for existing disktarget dev='hdc'//disk and tray state.
 If tray state is closed, this creates new xml that changes the source
file='...'/, and calls virDomainUpdateDeviceFlags with the new XML,
which in turn attempts the 'change' monitor command which tries to open
the tray, swap the media, then close the tray; this will fail if the
guest has mounted the previous media and thus locked the tray.  If tray
state is open, then this maps to the 'blockdev-media-insert' monitor
command that changes the media but leaves the tray open.

change-disk dom hdc --live --force /path/to/my.iso
= likewise, but with the force flag passed to
virDomainUpdateDeviceFlags, and thus to the 'change' monitor command, so
it should succeed

change-disk dom hdc
= changes the xml source to be empty, effectively removing the media
from the disk

change-disk dom hdc --open --keep
= changes the xml to request the new tray=open attribute, but leaves
source alone, so that the guest could initiate a tray-close action and
see the same .iso that was previously in the disk

change-disk dom hdc --close /path/to/my.iso
= ensure that the new tray state is closed and contains the new iso,
even if the tray was previously opened

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list