Re: [PATCH] virsh: domdisplay: if listen is 0.0.0.0 or [::] print address from URI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 30, 2016 at 16:45:32 +0200, Pavel Hrdina wrote:
> Currently if a guest has listen address 0.0.0.0 or [::] and you run
> "virsh domdisplay $domain" you always get "spice://localhost:$port".
> 
> We want to print better address if someone is connected from a different
> computer using "virsh -c qemu+ssh://some.host/system".  This patch fixes the
> behavior of virsh to print in this case "spice://some.host:$port".
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1332446
> 
> Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
> ---
>  tools/virsh-domain.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 8d7ff61..93c7050 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -57,6 +57,7 @@
>  #include "virtypedparam.h"
>  #include "virxml.h"
>  #include "virsh-nodedev.h"
> +#include "viruri.h"
>  
>  /* Gnulib doesn't guarantee SA_SIGINFO support.  */
>  #ifndef SA_SIGINFO
> @@ -10617,6 +10618,23 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
>              VIR_FREE(xpath);
>          }
>  
> +        /* If listen_addr is 0.0.0.0 or [::] we should try to parse URI and set
> +         * listen_addr based on current URI. */
> +        if (listen_addr) {
> +            if (virSocketAddrParse(&addr, listen_addr, AF_UNSPEC) > 0 &&
> +                virSocketAddrIsWildcard(&addr)) {
> +
> +                virURIPtr uri = virURIParse(ctl->connname);

ctl->conname contains the string that the user passed on the
commandline. Sice we are supporting aliases present in the config file
the string may be translated to something completely different and thus
can't be used as an uri here.

You need to extract the actual virsh connection from
((virshControlPtr)(ctl->privData))->dconn and then call virConnectGetURI
to get the actual URI.

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]