[libvirt] devAlias correct parsing

Hello, I would be grateful if you help me with next thing: I've successfully subscribed on VIR_DOMAIN_EVENT_ID_TRAY_CHANGE event in my application (QEMU based). It perfectly works and returns to me an device alias (e.g. "drive-scsi0-0-1-0"). Of course I can split this string by delimiter '-'. However, I've found private virDomainDefFindDevice function within libvirt and seems that its make correct parsing. How can I use it in my code? Thank you! -- Regards, Alexander Burluka

On Wed, Feb 17, 2016 at 04:20:58PM +0300, Alexander Burluka wrote:
Hello,
I would be grateful if you help me with next thing: I've successfully subscribed on VIR_DOMAIN_EVENT_ID_TRAY_CHANGE event in my application (QEMU based). It perfectly works and returns to me an device alias (e.g. "drive-scsi0-0-1-0"). Of course I can split this string by delimiter '-'. However, I've found private virDomainDefFindDevice function within libvirt and seems that its make correct parsing. How can I use it in my code?
You should not need to parse these strings at all. The alias in any event is supposed to match the <alias> against the corresponding device in the XML. You should treat them as opaque strings. 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 :|

Oh, I see, thanks for fast help. And what is recommended way of identifying device? For example, if application need to change ISO on that event in domain cdrom? On 02/17/2016 04:26 PM, Daniel P. Berrange wrote:
On Wed, Feb 17, 2016 at 04:20:58PM +0300, Alexander Burluka wrote:
Hello,
I would be grateful if you help me with next thing: I've successfully subscribed on VIR_DOMAIN_EVENT_ID_TRAY_CHANGE event in my application (QEMU based). It perfectly works and returns to me an device alias (e.g. "drive-scsi0-0-1-0"). Of course I can split this string by delimiter '-'. However, I've found private virDomainDefFindDevice function within libvirt and seems that its make correct parsing. How can I use it in my code? You should not need to parse these strings at all. The alias in any event is supposed to match the <alias> against the corresponding device in the XML. You should treat them as opaque strings.
Regards, Daniel
-- Regards, Alexander Burluka
participants (2)
-
Alexander Burluka
-
Daniel P. Berrange