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

Re: [Libguestfs] [PATCH] Enable new-style -chardev ... guestfwd command line



Richard W.M. Jones wrote:
> This also changes the name of the "vmchannel" buffer to just "buf",
> reflecting the fact that it's just used as a temporary buffer, and
> that the word vmchannel is overloaded.
...

Looks good.

> -//#define GUESTFWD_ADDR "10.0.2.4"
> +#define GUESTFWD_ADDR "10.0.2.4"
>
>  /* GuestFS handle and connection. */
>  enum state { CONFIG, LAUNCHING, READY, BUSY, NO_HANDLE };
> @@ -983,7 +983,7 @@ guestfs__launch (guestfs_h *g)
>    }
>
>    if (r == 0) {			/* Child (qemu). */
> -    char vmchannel[256];
> +    char buf[256];

Is 256 guaranteed to be enough?  I.e., who controls "unixsock"?
If not, failing snprintf will leave you with a truncated command string.

...
> +      snprintf (buf, sizeof buf,
> +                "socket,id=guestfsvmc,path=%s,server,nowait", unixsock);
> +
> +      add_cmdline (g, "-chardev");
> +      add_cmdline (g, buf);
> +
> +      snprintf (buf, sizeof buf,
> +                "user,vlan=0,net=10.0.2.0/8,"
> +                "guestfwd=tcp:%s:%d-chardev:guestfsvmc",
> +                GUESTFWD_ADDR, GUESTFWD_PORT);
...
>        add_cmdline (g, "user,vlan=0,net=10.0.2.0/8");

Note the two hard-coded net strings, "10.0.2.0/8".
It'd be nice to factor those out.
They could even be derived from the value of GUESTFWD_ADDR.


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