[libvirt] Is a libvirt connection remote?
Cole Robinson
crobinso at redhat.com
Mon Apr 18 14:37:08 UTC 2011
On 04/18/2011 08:16 AM, Richard W.M. Jones wrote:
> What's a good way to ask if a libvirt connection is remote or not?
> (Fundamentally I want to know if the disk images are openable as local
> files, and I'm using "remote" as an proxy for this property.)
>
> One way might be to compare virConnectGetHostname with the local
> hostname. This would fail if the client and server had the hostname
> set incorrectly (eg. "localhost.localdomain").
>
> Another way might be some hairy libvirt URL parsing.
This is what we do in virt-manager, we just assume that presence of a hostname
== remote. Granted that will incorrectly match qemu+ssh://localhost/system but
I can't think of a valid use case for that besides testing.
- Cole
>
> Another way would be to speculatively open the disk images. This
> would fail if the client and server had guests with coincidentally
> named disk images.
>
> Or I could write a qemu block driver that could use
> virDomainBlockPeek.
>
> Rich.
>
More information about the libvir-list
mailing list