[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v1 02/26] char-socket: allow vsock parameters (cid, port)
From: |
Adalbert Lazăr |
Subject: |
Re: [RFC PATCH v1 02/26] char-socket: allow vsock parameters (cid, port) |
Date: |
Wed, 15 Apr 2020 15:09:31 +0300 |
User-agent: |
void |
On Wed, 15 Apr 2020 12:43:31 +0200, Marc-André Lureau <address@hidden> wrote:
> Hi
>
> On Wed, Apr 15, 2020 at 3:00 AM Adalbert Lazăr <address@hidden> wrote:
> >
> > The introspection tool can run in a separate VM and the introspected
> > VM will establish a connection using a virtual socket.
> >
> > CC: "Marc-André Lureau" <address@hidden>
> > CC: Paolo Bonzini <address@hidden>
> > Signed-off-by: Adalbert Lazăr <address@hidden>
>
> We should also add QMP support.
>
The virtual socket seems to be created with the next QMP command:
{
"execute" : "chardev-add", "arguments" :
{
"id" : "id1", "backend" :
{
"type" : "socket", "data" :
{
"reconnect" : 10, "addr" :
{
"type" : "vsock", "data" : { "cid" : "321", "port" : "1234" }
}
}
}
}
}
>From what I remember, only the creation from command line was missing.
> Please add some tests in tests/test-char.c.
>
Sure.
Thanks.
> > ---
> > chardev/char-socket.c | 27 ++++++++++++++++++++++++---
> > chardev/char.c | 3 +++
> > 2 files changed, 27 insertions(+), 3 deletions(-)
> >
> > diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> > index bd966aace1..9b2deb0125 100644
> > --- a/chardev/char-socket.c
> > +++ b/chardev/char-socket.c
> > @@ -23,6 +23,11 @@
> > */
> >
> > #include "qemu/osdep.h"
> > +
> > +#ifdef CONFIG_AF_VSOCK
> > +#include <linux/vm_sockets.h>
> > +#endif /* CONFIG_AF_VSOCK */
> > +
> > #include "chardev/char.h"
> > #include "io/channel-socket.h"
> > #include "io/channel-tls.h"
> > @@ -590,6 +595,14 @@ static char *qemu_chr_compute_filename(SocketChardev
> > *s)
> > s->is_listen ? ",server" : "",
> > left, phost, right, pserv);
> >
> > +#ifdef CONFIG_AF_VSOCK
> > + case AF_VSOCK:
> > + return g_strdup_printf("vsock:%d:%d%s",
> > + ((struct sockaddr_vm *)(ss))->svm_cid,
> > + ((struct sockaddr_vm *)(ss))->svm_port,
> > + s->is_listen ? ",server" : "");
> > +#endif
> > +
> > default:
> > return g_strdup_printf("unknown");
> > }
> > @@ -1378,18 +1391,19 @@ static void qemu_chr_parse_socket(QemuOpts *opts,
> > ChardevBackend *backend,
> > {
> > const char *path = qemu_opt_get(opts, "path");
> > const char *host = qemu_opt_get(opts, "host");
> > + const char *cid = qemu_opt_get(opts, "cid");
> > const char *port = qemu_opt_get(opts, "port");
> > const char *fd = qemu_opt_get(opts, "fd");
> > SocketAddressLegacy *addr;
> > ChardevSocket *sock;
> >
> > - if ((!!path + !!fd + !!host) != 1) {
> > + if ((!!path + !!fd + !!host + !!cid) != 1) {
> > error_setg(errp,
> > - "Exactly one of 'path', 'fd' or 'host' required");
> > + "Exactly one of 'path', 'fd', 'cid' or 'host'
> > required");
> > return;
> > }
> >
> > - if (host && !port) {
> > + if ((host || cid) && !port) {
> > error_setg(errp, "chardev: socket: no port given");
> > return;
> > }
> > @@ -1444,6 +1458,13 @@ static void qemu_chr_parse_socket(QemuOpts *opts,
> > ChardevBackend *backend,
> > .has_ipv6 = qemu_opt_get(opts, "ipv6"),
> > .ipv6 = qemu_opt_get_bool(opts, "ipv6", 0),
> > };
> > + } else if (cid) {
> > + addr->type = SOCKET_ADDRESS_LEGACY_KIND_VSOCK;
> > + addr->u.vsock.data = g_new0(VsockSocketAddress, 1);
> > + *addr->u.vsock.data = (VsockSocketAddress) {
> > + .cid = g_strdup(cid),
> > + .port = g_strdup(port),
> > + };
> > } else if (fd) {
> > addr->type = SOCKET_ADDRESS_LEGACY_KIND_FD;
> > addr->u.fd.data = g_new(String, 1);
> > diff --git a/chardev/char.c b/chardev/char.c
> > index e77564060d..39e36ceb97 100644
> > --- a/chardev/char.c
> > +++ b/chardev/char.c
> > @@ -852,6 +852,9 @@ QemuOptsList qemu_chardev_opts = {
> > },{
> > .name = "host",
> > .type = QEMU_OPT_STRING,
> > + },{
> > + .name = "cid",
> > + .type = QEMU_OPT_STRING,
> > },{
> > .name = "port",
> > .type = QEMU_OPT_STRING,
> >
>
>
> --
> Marc-André Lureau
- Re: [RFC PATCH v1 04/26] char-socket: add 'reconnecting' property, (continued)
- [RFC PATCH v1 06/26] E820: extend the table access interface, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 07/26] linux-headers: update with VM introspection interface, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 05/26] char-socket: add 'fd' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 13/26] kvm: vmi: block the object destruction if the chardev is connected, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 09/26] kvm: introduce the VM introspection object, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 02/26] char-socket: allow vsock parameters (cid, port), Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 01/26] chardev: tcp: allow to change the reconnect timer, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 14/26] kvm: vmi: allow only one instance of the introspection object, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 11/26] kvm: vmi: add 'handshake_timeout' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 15/26] kvm: vmi: reconnect the socket on reset, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 19/26] kvm: vmi: intercept force-reset, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 22/26] kvm: vmi: add 'async_unhook' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 17/26] kvm: vmi: add 'unhook_timeout' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 24/26] kvm: vmi: add 'unhook_on_shutdown' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 12/26] kvm: vmi: add 'key' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 21/26] kvm: vmi: postpone the OK response from qmp_stop(), Adalbert Lazăr, 2020/04/14