On Fri, Aug 12, 2011 at 09:34:41PM +0800, Osier Yang wrote: > Intorduce new monitor functions to get the media status (ejected > or inserted) of removable block device via qemu monitor command > "info block". > > QEMU upstream will expose the the media status like: > cd: type=cdrom removable=1 locked=0 ejected=0 > > The related patch: > http://lists.gnu.org/archive/html/qemu-devel/2011-08/msg00408.html Hmm, that patch isn't merged upstream yet. We ought to wait for it to be merged, since historically discussions about this kind of thing on QEMU-devel have been quiet unpredictable. > > Although it's unlikely to expose other information of removable > block device in future via the new function, returned the info > in argument "*ejected" just in case of there is new requirement > to expose other info. > --- > src/qemu/qemu_monitor.c | 20 ++++++++ > src/qemu/qemu_monitor.h | 3 + > src/qemu/qemu_monitor_json.c | 14 ++++++ > src/qemu/qemu_monitor_json.h | 4 +- > src/qemu/qemu_monitor_text.c | 105 ++++++++++++++++++++++++++++++++++++++++++ > src/qemu/qemu_monitor_text.h | 3 + > 6 files changed, 148 insertions(+), 1 deletions(-) > > diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c > index db6107c..7a41e8f 100644 > --- a/src/qemu/qemu_monitor.c > +++ b/src/qemu/qemu_monitor.c > @@ -1227,6 +1227,26 @@ int qemuMonitorGetBlockStatsInfo(qemuMonitorPtr mon, > return ret; > } > > +int qemuMonitorGetRemovableBlockMediaStatus(qemuMonitorPtr mon, > + const char *devname, > + unsigned int *ejected) The last arg should really be 'bool *ejected' > diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c > index 2a9a078..f59489d 100644 > --- a/src/qemu/qemu_monitor_json.c > +++ b/src/qemu/qemu_monitor_json.c > @@ -1519,6 +1519,20 @@ cleanup: > return ret; > } > > +int qemuMonitorJSONGetRemovableBlockMediaStatus(qemuMonitorPtr mon, > + const char *devname, > + unsigned int *ejected) > +{ > + /* XXX: No QMP command like "info block" which can get the > + * block device information yet. > + */ This is not correct, it is simply called 'query-block' Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list